From a6ced90efccf869defc0b310effca220f01cf318 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Wed, 8 Feb 2017 02:18:33 +0000 Subject: [PATCH] test: Fix some memory leaks in test-font.c (#409) Coverity IDs: 141039, 141040, 141041 --- test/api/test-font.c | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/test/api/test-font.c b/test/api/test-font.c index 34f6c746e..527dfcdc1 100644 --- a/test/api/test-font.c +++ b/test/api/test-font.c @@ -35,13 +35,23 @@ static const char test_data[] = "test\0data"; static void test_face_empty (void) { + hb_face_t *created_from_empty; + hb_face_t *created_from_null; + g_assert (hb_face_get_empty ()); - g_assert (hb_face_get_empty () != hb_face_create (hb_blob_get_empty (), 0)); - g_assert (hb_face_get_empty () != hb_face_create (NULL, 0)); + + created_from_empty = hb_face_create (hb_blob_get_empty (), 0); + g_assert (hb_face_get_empty () != created_from_empty); + + created_from_null = hb_face_create (NULL, 0); + g_assert (hb_face_get_empty () != created_from_null); g_assert (hb_face_reference_table (hb_face_get_empty (), HB_TAG ('h','e','a','d')) == hb_blob_get_empty ()); g_assert_cmpint (hb_face_get_upem (hb_face_get_empty ()), ==, 1000); + + hb_face_destroy (created_from_null); + hb_face_destroy (created_from_empty); } static void @@ -357,14 +367,29 @@ test_fontfuncs_subclassing (void) static void test_font_empty (void) { + hb_font_t *created_from_empty; + hb_font_t *created_from_null; + hb_font_t *created_sub_from_null; + g_assert (hb_font_get_empty ()); - g_assert (hb_font_get_empty () != hb_font_create (hb_face_get_empty ())); - g_assert (hb_font_get_empty () != hb_font_create (NULL)); - g_assert (hb_font_get_empty () != hb_font_create_sub_font (NULL)); + + created_from_empty = hb_font_create (hb_face_get_empty ()); + g_assert (hb_font_get_empty () != created_from_empty); + + created_from_null = hb_font_create (NULL); + g_assert (hb_font_get_empty () != created_from_null); + + created_sub_from_null = hb_font_create_sub_font (NULL); + g_assert (hb_font_get_empty () != created_sub_from_null); + g_assert (hb_font_is_immutable (hb_font_get_empty ())); g_assert (hb_font_get_face (hb_font_get_empty ()) == hb_face_get_empty ()); g_assert (hb_font_get_parent (hb_font_get_empty ()) == NULL); + + hb_font_destroy (created_sub_from_null); + hb_font_destroy (created_from_null); + hb_font_destroy (created_from_empty); } static void