summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrcaridade145 <[email protected]>2020-01-11 13:10:12 +0000
committermonsta <[email protected]>2020-02-02 15:49:25 +0300
commit251a84f0e5450a3b89385097c62be9285b45b62a (patch)
treefc53b941a2640d2bf56f1f2ee203ca4e92bb3399 /src
parent50cc7c7f2b4b8975779a34c30c052fdd7a3aaf34 (diff)
downloadmarco-251a84f0e5450a3b89385097c62be9285b45b62a.tar.bz2
marco-251a84f0e5450a3b89385097c62be9285b45b62a.tar.xz
Xprops fix memory leak.
Origin commit : https://gitlab.gnome.org/GNOME/metacity/commit/c87f73f3b4413720a2f3e6a672826d3fec7f77a9 " XmbTextPropertyToTextList documentation says that XFreeStringList should be used to free the storage for the list and its contents. "
Diffstat (limited to 'src')
-rw-r--r--src/core/xprops.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/core/xprops.c b/src/core/xprops.c
index 80dd7b59..938bdce4 100644
--- a/src/core/xprops.c
+++ b/src/core/xprops.c
@@ -652,21 +652,27 @@ text_property_to_utf8 (Display *xdisplay,
{
char *ret = NULL;
char **local_list = NULL;
+ const char *charset = NULL;
int count = 0;
int res;
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;
+ }
- ret = g_strdup (local_list[0]);
+ 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