Revert "shared/compat: fix memory handling of nm_setting_vpn_get_*_keys"

This reverts commit 8ac8c01162.

The fix was bad because the keys do not come from NMSettingVpn's hash
table but are copies that are freed by nm_setting_vpn_foreach_* before
it returns.

https://mail.gnome.org/archives/networkmanager-list/2017-December/msg00069.html
This commit is contained in:
Jan Alexander Steffens (heftig) 2017-12-21 20:36:48 +01:00 committed by Thomas Haller
parent 60d4b370ba
commit 64fcfc62bb

View file

@ -30,7 +30,7 @@ _get_keys_cb (const char *key, const char *val, gpointer user_data)
{
GPtrArray *a = user_data;
g_ptr_array_add (a, (gpointer) key);
g_ptr_array_add (a, g_strdup (key));
}
static const char **
@ -55,6 +55,14 @@ _get_keys (NMSettingVpn *setting,
g_ptr_array_sort (a, nm_strcmp_p);
g_ptr_array_add (a, NULL);
keys = (const char **) g_ptr_array_free (g_steal_pointer (&a), FALSE);
/* we need to cache the keys *somewhere*. */
g_object_set_qdata_full (G_OBJECT (setting),
is_secrets
? NM_CACHED_QUARK ("libnm._nm_setting_vpn_get_secret_keys")
: NM_CACHED_QUARK ("libnm._nm_setting_vpn_get_data_keys"),
keys,
(GDestroyNotify) g_strfreev);
}
NM_SET_OUT (out_length, len);