[gnome-control-center] keyboard: Fix a memory leak
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] keyboard: Fix a memory leak
- Date: Fri, 30 Jun 2017 00:27:07 +0000 (UTC)
commit 870fb462019701f7c0bdf2f1cdeefa94f2575e67
Author: Florian Müllner <fmuellner gnome org>
Date: Thu Jun 29 16:42:43 2017 +0200
keyboard: Fix a memory leak
While the actual strings returned by g_variant_get_strv() are owned
by the variant, we still need to free the container ...
https://bugzilla.gnome.org/show_bug.cgi?id=784356
panels/keyboard/cc-keyboard-manager.c | 12 +++++++++---
1 files changed, 9 insertions(+), 3 deletions(-)
---
diff --git a/panels/keyboard/cc-keyboard-manager.c b/panels/keyboard/cc-keyboard-manager.c
index 84e1e15..7e47b29 100644
--- a/panels/keyboard/cc-keyboard-manager.c
+++ b/panels/keyboard/cc-keyboard-manager.c
@@ -87,12 +87,18 @@ free_key_array (GPtrArray *keys)
static const gchar*
get_binding_from_variant (GVariant *variant)
{
+ const char *str, **strv;
+
if (g_variant_is_of_type (variant, G_VARIANT_TYPE_STRING))
return g_variant_get_string (variant, NULL);
- else if (g_variant_is_of_type (variant, G_VARIANT_TYPE_STRING_ARRAY))
- return g_variant_get_strv (variant, NULL)[0];
+ else if (!g_variant_is_of_type (variant, G_VARIANT_TYPE_STRING_ARRAY))
+ return NULL;
+
+ strv = g_variant_get_strv (variant, NULL);
+ str = strv[0];
+ g_free (strv);
- return NULL;
+ return str;
}
static gboolean
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]