ghash: Clear out arguments to NULL in g_hash_table_lookup_extended()

If the given key is not found, clear the orig_key and value arguments to
NULL as well as returning FALSE. Then the caller can unconditionally
check them.

This makes the behaviour of g_hash_table_lookup_extended() consistent
with g_hash_table_steal_extended().

Signed-off-by: Philip Withnall <withnall@endlessm.com>
This commit is contained in:
Philip Withnall 2018-08-31 12:45:29 +01:00
parent ea17d637c5
commit 8dc8b33dfa

View File

@ -1190,7 +1190,14 @@ g_hash_table_lookup_extended (GHashTable *hash_table,
node_index = g_hash_table_lookup_node (hash_table, lookup_key, &node_hash);
if (!HASH_IS_REAL (hash_table->hashes[node_index]))
return FALSE;
{
if (orig_key != NULL)
*orig_key = NULL;
if (value != NULL)
*value = NULL;
return FALSE;
}
if (orig_key)
*orig_key = hash_table->keys[node_index];