From eed74317c41de82405795de180e37f45423b424b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Fri, 30 Jun 2017 18:06:52 +0200 Subject: [PATCH] keyboard: Fix another memory leak The memory leak fixed in commit 870fb462019 is still present in a copy-pasted version of the function, apply the same fix there as well ... https://bugzilla.gnome.org/show_bug.cgi?id=784356 --- panels/keyboard/cc-keyboard-item.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/panels/keyboard/cc-keyboard-item.c b/panels/keyboard/cc-keyboard-item.c index 619474c95..d6f9938d6 100644 --- a/panels/keyboard/cc-keyboard-item.c +++ b/panels/keyboard/cc-keyboard-item.c @@ -63,12 +63,18 @@ G_DEFINE_TYPE (CcKeyboardItem, cc_keyboard_item, G_TYPE_OBJECT) 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 + else if (!g_variant_is_of_type (variant, G_VARIANT_TYPE_STRING_ARRAY)) return ""; + + strv = g_variant_get_strv (variant, NULL); + str = strv[0]; + g_free (strv); + + return str; } static gboolean