diff options
author | rcaridade145 <[email protected]> | 2020-01-11 13:10:12 +0000 |
---|---|---|
committer | raveit65 <[email protected]> | 2020-01-22 11:13:40 +0100 |
commit | 0c748e0d1ce08e9c7a13a4bf84a0ac43d79ffcdf (patch) | |
tree | e8f333060a30dea33abc2786b63c2730c44864f0 /src | |
parent | 5405b8b210c738f430e1a502e056445f15579bb0 (diff) | |
download | marco-0c748e0d1ce08e9c7a13a4bf84a0ac43d79ffcdf.tar.bz2 marco-0c748e0d1ce08e9c7a13a4bf84a0ac43d79ffcdf.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.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/src/core/xprops.c b/src/core/xprops.c index ea869799..f1b21f00 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; - - ret = g_strdup (local_list[0]); + { + 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 |