From 226d1a898a73de3a0fc09247c83dceac7b5c8786 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Wed, 8 Jul 2020 23:00:54 -0400 Subject: Fix a few memory leaks in tests These were pointed out by asan. --- tests/test-common.c | 12 ++++++++++-- tests/testboundaries_ucd.c | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/tests/test-common.c b/tests/test-common.c index 786973f1..60ecb7e1 100644 --- a/tests/test-common.c +++ b/tests/test-common.c @@ -125,14 +125,22 @@ print_attribute (PangoAttribute *attr, GString *string) g_string_append_printf (string, "%d", ((PangoAttrInt *)attr)->value); break; case PANGO_ATTR_FONT_DESC: - g_string_append_printf (string, "%s", pango_font_description_to_string (((PangoAttrFontDesc *)attr)->desc)); + { + char *text = pango_font_description_to_string (((PangoAttrFontDesc *)attr)->desc); + g_string_append_printf (string, "%s", text); + g_free (text); + } break; case PANGO_ATTR_FOREGROUND: case PANGO_ATTR_BACKGROUND: case PANGO_ATTR_UNDERLINE_COLOR: case PANGO_ATTR_OVERLINE_COLOR: case PANGO_ATTR_STRIKETHROUGH_COLOR: - g_string_append_printf (string, "%s", pango_color_to_string (&((PangoAttrColor *)attr)->color)); + { + char *text = pango_color_to_string (&((PangoAttrColor *)attr)->color); + g_string_append_printf (string, "%s", text); + g_free (text); + } break; case PANGO_ATTR_SHAPE: g_string_append_printf (string, "shape"); diff --git a/tests/testboundaries_ucd.c b/tests/testboundaries_ucd.c index f77abdcd..18ab94cc 100644 --- a/tests/testboundaries_ucd.c +++ b/tests/testboundaries_ucd.c @@ -298,6 +298,7 @@ do_test (const gchar *filename, } g_free (string); g_free (expected_attrs); + g_free (line); i++; } -- cgit v1.2.1