mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager
synced 2024-07-21 18:24:49 +00:00
libnm-util: only unref and don't destroy hash in nm_connection_to_hash()
The returned hash from nm_connection_to_hash() used to destroy the nested hashes, instead of only unrefing them.
This commit is contained in:
parent
1567a9f712
commit
027ab3efaa
|
@ -1241,7 +1241,7 @@ nm_connection_to_hash (NMConnection *connection, NMSettingHashFlags flags)
|
|||
g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
|
||||
|
||||
ret = g_hash_table_new_full (g_str_hash, g_str_equal,
|
||||
g_free, (GDestroyNotify) g_hash_table_destroy);
|
||||
g_free, (GDestroyNotify) g_hash_table_unref);
|
||||
|
||||
priv = NM_CONNECTION_GET_PRIVATE (connection);
|
||||
|
||||
|
|
|
@ -650,20 +650,22 @@ test_update_secrets_whole_connection_bad_setting (void)
|
|||
secrets = nm_connection_to_hash (connection, NM_SETTING_HASH_FLAG_ALL);
|
||||
wsec_hash = g_hash_table_lookup (secrets, NM_SETTING_WIRELESS_SECURITY_SETTING_NAME);
|
||||
g_assert (wsec_hash);
|
||||
g_hash_table_insert (wsec_hash, NM_SETTING_WIRELESS_SECURITY_WEP_KEY0, string_to_gvalue (wepkey));
|
||||
g_hash_table_insert (wsec_hash, g_strdup (NM_SETTING_WIRELESS_SECURITY_WEP_KEY0), string_to_gvalue (wepkey));
|
||||
|
||||
/* Steal the wsec setting hash so it's not deallocated, and stuff it back
|
||||
* in with a different name so we ensure libnm-util is returning the right
|
||||
* error when it finds an entry in the connection hash that doesn't match
|
||||
* any setting in the connection.
|
||||
*/
|
||||
g_hash_table_steal (secrets, NM_SETTING_WIRELESS_SECURITY_SETTING_NAME);
|
||||
g_hash_table_insert (secrets, "asdfasdfasdfasdf", wsec_hash);
|
||||
g_hash_table_ref (wsec_hash);
|
||||
g_hash_table_remove (secrets, NM_SETTING_WIRELESS_SECURITY_SETTING_NAME);
|
||||
g_hash_table_insert (secrets, g_strdup ("asdfasdfasdfasdf"), wsec_hash);
|
||||
|
||||
success = nm_connection_update_secrets (connection, NULL, secrets, &error);
|
||||
g_assert_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_SETTING_NOT_FOUND);
|
||||
g_assert (success == FALSE);
|
||||
|
||||
g_hash_table_destroy (secrets);
|
||||
g_object_unref (connection);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue