diff options
| author | Rui Matos <tiagomatos@gmail.com> | 2017-02-21 14:49:09 (GMT) |
|---|---|---|
| committer | Rui Matos <tiagomatos@gmail.com> | 2017-02-21 18:51:46 (GMT) |
| commit | 5ba38a4ab6913fc5a4005ec3195df6bff5e89821 (patch) | |
| tree | 9c936be90c887fee27df3122ccb2f76dc70820f1 | |
| parent | 8f5a0ec83daf135b91d5fce44db5da7862958f7a (diff) | |
| download | mutter-5ba38a4ab6913fc5a4005ec3195df6bff5e89821.zip mutter-5ba38a4ab6913fc5a4005ec3195df6bff5e89821.tar.xz | |
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
| -rw-r--r-- | src/x11/xprops.c | 24 |
1 files 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; |