File mutter-bsc1017412-property-results-memory-leak.patch of Package mutter.9448
From 979c24a772ff6d298bbb7bd6938feefd528bdff3 Mon Sep 17 00:00:00 2001
From: Rui Matos <tiagomatos@gmail.com>
Date: Tue, 21 Feb 2017 15:49:09 +0100
Subject: [PATCH] x11/xprops: Plug a few memory leaks
Commits 6dbec6f8, 734402e1 and f041b35b introduced memory leaks by
switching to returning copies instead of the original buffers but
forgetting to free those original buffers.
Some error cases were also not freeing the ->prop buffer as they
should.
https://bugzilla.gnome.org/show_bug.cgi?id=642652
---
src/x11/xprops.c | 24 ++++++++++++++++++++++--
1 file changed, 22 insertions(+), 2 deletions(-)
diff --git a/src/x11/xprops.c b/src/x11/xprops.c
index e3bd931..cffa595 100644
--- a/src/x11/xprops.c
+++ b/src/x11/xprops.c
@@ -304,6 +304,8 @@ motif_hints_from_results (GetPropertyResults *results,
if (results->type == None || results->n_items <= 0)
{
+ g_free (results->prop);
+ results->prop = NULL;
meta_verbose ("Motif hints had unexpected type or n_items\n");
return FALSE;
}
@@ -314,10 +316,18 @@ motif_hints_from_results (GetPropertyResults *results,
*/
*hints_p = calloc (1, sizeof (MotifWmHints));
if (*hints_p == NULL)
- return FALSE;
+ {
+ g_free (results->prop);
+ results->prop = NULL;
+ return FALSE;
+ }
memcpy(*hints_p, results->prop, MIN (sizeof (MotifWmHints),
results->n_items * sizeof (uint32_t)));
+
+ g_free (results->prop);
+ results->prop = NULL;
+
return TRUE;
}
@@ -349,6 +359,9 @@ latin1_string_from_results (GetPropertyResults *results,
*str_p = g_strndup ((char *) results->prop, results->n_items);
+ g_free (results->prop);
+ results->prop = NULL;
+
return TRUE;
}
@@ -396,6 +409,9 @@ utf8_string_from_results (GetPropertyResults *results,
*str_p = g_strndup ((char *) results->prop, results->n_items);
+ g_free (results->prop);
+ results->prop = NULL;
+
return TRUE;
}
@@ -772,7 +788,11 @@ size_hints_from_results (GetPropertyResults *results,
return FALSE;
if (results->n_items < OldNumPropSizeElements)
- return FALSE;
+ {
+ g_free (results->prop);
+ results->prop = NULL;
+ return FALSE;
+ }
raw = (xPropSizeHints*) results->prop;
--
2.9.3