[cairo-commit] 2 commits - src/cairo-cff-subset.c src/cairo-pdf-surface.c src/cairo-truetype-subset.c test/pdf-mime-data.c

Bryce Harrington bryce at kemper.freedesktop.org
Fri May 16 11:11:54 PDT 2014


 src/cairo-cff-subset.c      |    4 +++-
 src/cairo-pdf-surface.c     |    8 +++++++-
 src/cairo-truetype-subset.c |    4 ++--
 test/pdf-mime-data.c        |    2 ++
 4 files changed, 14 insertions(+), 4 deletions(-)

New commits:
commit 247cfaaa2562d28ee39a5a35eea9772ee365937b
Author: Sylvestre Ledru <sylvestre at debian.org>
Date:   Wed May 7 17:15:22 2014 +0200

    Fix some memory leaks found by scan-build, the LLVM/Clang static analyzer
    
    Signed-off-by: Bryce Harrington <b.harrington at samsung.com>
    Reviewed-by: Uli Schlachter <psychon at znc.in>

diff --git a/src/cairo-cff-subset.c b/src/cairo-cff-subset.c
index 1ae032c..1bb9461 100644
--- a/src/cairo-cff-subset.c
+++ b/src/cairo-cff-subset.c
@@ -1851,8 +1851,10 @@ cairo_cff_font_subset_fontdict (cairo_cff_font_t  *font)
     for (i = 0; i < font->scaled_font_subset->num_glyphs; i++) {
 	cid = font->scaled_font_subset->glyphs[i];
 	status = cairo_cff_font_get_gid_for_cid (font, cid, &gid);
-	if (unlikely (status))
+	if (unlikely (status)) {
+	    free (reverse_map);
 	    return status;
+	}
 
         fd = font->fdselect[gid];
         if (reverse_map[fd] < 0) {
diff --git a/src/cairo-pdf-surface.c b/src/cairo-pdf-surface.c
index c200c28..602d519 100644
--- a/src/cairo-pdf-surface.c
+++ b/src/cairo-pdf-surface.c
@@ -2642,11 +2642,17 @@ _cairo_pdf_surface_lookup_jbig2_global (cairo_pdf_surface_t       *surface,
     }
 
     global.id = malloc(global_id_length);
+    if (unlikely (global.id == NULL)) {
+	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
+    }
+
     memcpy (global.id, global_id, global_id_length);
     global.id_length = global_id_length;
     global.res = _cairo_pdf_surface_new_object (surface);
-    if (global.res.id == 0)
+    if (global.res.id == 0) {
+	free(global.id);
 	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
+    }
 
     global.emitted = FALSE;
     status = _cairo_array_append (&surface->jbig2_global, &global);
diff --git a/test/pdf-mime-data.c b/test/pdf-mime-data.c
index c575c4a..e2c529e 100644
--- a/test/pdf-mime-data.c
+++ b/test/pdf-mime-data.c
@@ -105,6 +105,7 @@ preamble (cairo_test_context_t *ctx)
     test_status = read_file (ctx, IMAGE_FILE ".jpg", &data, &len);
     if (test_status) {
 	cairo_test_log (ctx, "Could not read input jpeg file %s\n", IMAGE_FILE ".jpg");
+	free(data);
 	return test_status;
     }
 
@@ -149,6 +150,7 @@ preamble (cairo_test_context_t *ctx)
     test_status = read_file (ctx, IMAGE_FILE ".jpg", &data, &len);
     if (test_status) {
 	cairo_test_log (ctx, "Could not read input jpeg file %s\n", IMAGE_FILE ".jpg");
+	free(data);
 	return test_status;
     }
 
commit 5e7b724dd3ed13c7c5a6ffe3874ad21b7fbe2176
Author: Sylvestre Ledru <sylvestre at debian.org>
Date:   Wed May 7 17:16:09 2014 +0200

    Remove some potential double free
    
    Signed-off-by: Bryce Harrington <b.harrington at samsung.com>
    Reviewed-by: Uli Schlachter <psychon at znc.in>

diff --git a/src/cairo-truetype-subset.c b/src/cairo-truetype-subset.c
index 3d55fef..645a89a 100644
--- a/src/cairo-truetype-subset.c
+++ b/src/cairo-truetype-subset.c
@@ -1564,12 +1564,12 @@ _cairo_truetype_read_font_name (cairo_scaled_font_t  	 *scaled_font,
 	    goto fail;
     }
 
-    free (name);
-
     status = _cairo_escape_ps_name (&ps_name);
     if (unlikely(status))
 	goto fail;
 
+    free (name);
+
     *ps_name_out = ps_name;
     *font_name_out = family_name;
 


More information about the cairo-commit mailing list