From dd28e792ee95dd428901ad98a02c210db23697a0 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Mon, 18 Apr 2016 17:19:02 +0200 Subject: [PATCH] libnm/vpn: clear internal "keyfile" from NMVpnPluginInfo The GKeyFile is no longer needed after constuction. All strings are copied over to the "keys" hash. (cherry picked from commit 4003edbbf91910d9da55e68381d5eb164ca9669c) --- libnm-core/nm-vpn-plugin-info.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/libnm-core/nm-vpn-plugin-info.c b/libnm-core/nm-vpn-plugin-info.c index 430f9125ed..2e6275e341 100644 --- a/libnm-core/nm-vpn-plugin-info.c +++ b/libnm-core/nm-vpn-plugin-info.c @@ -877,15 +877,16 @@ init_sync (GInitable *initable, GCancellable *cancellable, GError **error) for (j = 0; keys && keys[j]; j++) { char *s; - /* Lookup the value via get_string(). We want that behavior. - * You could still lookup the original values via g_key_file_get_value() - * based on priv->keyfile. */ + /* Lookup the value via get_string(). We want that behavior for all our + * values. */ s = g_key_file_get_string (priv->keyfile, groups[i], keys[j], NULL); if (s) g_hash_table_insert (priv->keys, _nm_utils_strstrdictkey_create (groups[i], keys[j]), s); } } + g_clear_pointer (&priv->keyfile, g_key_file_unref); + return TRUE; } @@ -948,9 +949,10 @@ finalize (GObject *object) g_free (priv->service); g_strfreev (priv->aliases); g_free (priv->filename); - g_key_file_unref (priv->keyfile); g_hash_table_unref (priv->keys); + g_clear_pointer (&priv->keyfile, g_key_file_unref); + G_OBJECT_CLASS (nm_vpn_plugin_info_parent_class)->finalize (object); }