[cairo-commit] test/pdf-mime-data.c test/png.c

Bryce Harrington bryce at kemper.freedesktop.org
Wed Dec 9 11:30:55 PST 2015


 test/pdf-mime-data.c |    2 +-
 test/png.c           |    3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

New commits:
commit 0986ae4dee2a903dc16bba289477a38dff36a87b
Author: Bryce Harrington <bryce at osg.samsung.com>
Date:   Wed Dec 9 11:30:34 2015 -0800

    test: Fix use after frees
    
    Fixes:  https://bugs.freedesktop.org/show_bug.cgi?id=93152

diff --git a/test/pdf-mime-data.c b/test/pdf-mime-data.c
index b49a1d1..69fafa1 100644
--- a/test/pdf-mime-data.c
+++ b/test/pdf-mime-data.c
@@ -140,9 +140,9 @@ preamble (cairo_test_context_t *ctx)
     cairo_surface_destroy (image);
 
     if (status) {
-        free (filename);
 	cairo_test_log (ctx, "Failed to create pdf surface for file %s: %s\n",
 			filename, cairo_status_to_string (status));
+        free (filename);
 	return CAIRO_TEST_FAILURE;
     }
 
diff --git a/test/png.c b/test/png.c
index c01fbd7..cd11fd0 100644
--- a/test/png.c
+++ b/test/png.c
@@ -136,15 +136,16 @@ preamble (cairo_test_context_t *ctx)
     }
     surface1 = cairo_image_surface_create_from_png (filename);
     status = cairo_surface_status (surface1);
-    free (filename);
     if (status) {
 	cairo_test_log (ctx, "Error reading '%s': %s\n",
 			filename, cairo_status_to_string (status));
+	free (filename);
 
 	cairo_surface_destroy (surface1);
 	cairo_surface_destroy (surface0);
 	return cairo_test_status_from_status (ctx, status);
     }
+    free (filename);
 
     if (! image_surface_equals (surface0, surface1)) {
 	cairo_test_log (ctx, "Error surface mismatch.\n");


More information about the cairo-commit mailing list