summaryrefslogtreecommitdiff
path: root/test/bitmap-font.c
diff options
context:
space:
mode:
authorArpit Jain <jain.arpit@samsung.com>2015-07-03 15:31:48 +0530
committerBryce Harrington <bryce@osg.samsung.com>2015-07-06 15:14:23 -0700
commit943ba26a20f51b39b4b102f727a26e4f5e283063 (patch)
tree28c66089197bcf38806413a5dda9c869a79d104d /test/bitmap-font.c
parentdced42a6801ea0f7ff9fa9f7aa3c7b2a10103884 (diff)
downloadcairo-943ba26a20f51b39b4b102f727a26e4f5e283063.tar.gz
test/bitmap-font: Fix use of pointer after freed pointer
The pointer 'filename' is already freed and still used as a function argument. This patch will free the pointer 'filename' only after it is used. Also, the patch ensures that it frees the pointer 'filename' before any return of this function. Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=91206 Signed-off-by: Arpit Jain <jain.arpit@samsung.com> Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
Diffstat (limited to 'test/bitmap-font.c')
-rw-r--r--test/bitmap-font.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/test/bitmap-font.c b/test/bitmap-font.c
index 0ec9b3de5..525bafb2a 100644
--- a/test/bitmap-font.c
+++ b/test/bitmap-font.c
@@ -94,9 +94,9 @@ draw (cairo_t *cr, int width, int height)
}
pattern = FcFreeTypeQuery ((unsigned char *)filename, 0, NULL, &face_count);
- free (filename);
if (! pattern) {
cairo_test_log (ctx, "FcFreeTypeQuery failed.\n");
+ free (filename);
return cairo_test_status_from_status (ctx, CAIRO_STATUS_NO_MEMORY);
}
@@ -108,9 +108,11 @@ draw (cairo_t *cr, int width, int height)
cairo_test_log (ctx, "Error creating font face for %s: %s\n",
filename,
cairo_status_to_string (status));
+ free (filename);
return cairo_test_status_from_status (ctx, status);
}
+ free (filename);
if (cairo_font_face_get_type (font_face) != CAIRO_FONT_TYPE_FT) {
cairo_test_log (ctx, "Unexpected value from cairo_font_face_get_type: %d (expected %d)\n",
cairo_font_face_get_type (font_face), CAIRO_FONT_TYPE_FT);