[pango/test-leaks] Fix a few memory leaks in tests
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pango/test-leaks] Fix a few memory leaks in tests
- Date: Thu, 9 Jul 2020 03:01:38 +0000 (UTC)
commit 226d1a898a73de3a0fc09247c83dceac7b5c8786
Author: Matthias Clasen <mclasen redhat com>
Date: Wed Jul 8 23:00:54 2020 -0400
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++;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]