summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlberts Muktupāvels <alberts.muktupavels@gmail.com>2019-08-06 23:47:27 +0300
committerAlberts Muktupāvels <alberts.muktupavels@gmail.com>2019-08-06 23:47:27 +0300
commitc87f73f3b4413720a2f3e6a672826d3fec7f77a9 (patch)
treeeac4f0e41d64ce0d3f473801fd84b2ddd4dd50c2
parent229ff300d2f21c9af9329c77f5aa0403fe0089e7 (diff)
downloadmetacity-c87f73f3b4413720a2f3e6a672826d3fec7f77a9.tar.gz
xprops: fix memory leak
XmbTextPropertyToTextList documentation says that XFreeStringList should be used to free the storage for the list and its contents. https://gitlab.gnome.org/GNOME/metacity/issues/7
-rw-r--r--src/core/xprops.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/core/xprops.c b/src/core/xprops.c
index a1cd901f..4b701af7 100644
--- a/src/core/xprops.c
+++ b/src/core/xprops.c
@@ -674,19 +674,21 @@ text_property_to_utf8 (Display *xdisplay,
res = XmbTextPropertyToTextList (xdisplay, prop, &local_list, &count);
if (res == XNoMemory || res == XLocaleNotSupported || res == XConverterNotFound)
- goto out;
+ return NULL;
if (count == 0)
- goto out;
+ {
+ XFreeStringList (local_list);
+ return NULL;
+ }
if (g_get_charset (&charset))
ret = g_strdup (local_list[0]);
else
ret = g_convert (local_list[0], -1, "UTF-8", charset, NULL, NULL, NULL);
- out:
- meta_XFree (local_list);
- return ret;
+ XFreeStringList (local_list);
+ return ret;
}
static gboolean