extcap: Fix memory leak in extcap_get_if_configuration_values()

The content of the list returned by g_hash_table_get_keys() is owned by
GHashTable and should not be modified or freed. However, the list itself
should be freed using g_list_free().

This fixes memory leak that happened on every selector option reload.

Change-Id: Id91055264fed9f7b8ab8dba9292d5f35389ca235
Reviewed-on: https://code.wireshark.org/review/33244
Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
This commit is contained in:
Tomasz Moń 2019-05-18 09:34:04 +02:00 committed by Peter Wu
parent 92dede59a5
commit 40f6cb70e9
1 changed files with 5 additions and 3 deletions

View File

@ -995,13 +995,15 @@ extcap_get_if_configuration_values(const char * ifname, const char * argname, GH
if ( arguments )
{
GList * keys = g_hash_table_get_keys(arguments);
while ( keys )
GList * walker = g_list_first(keys);
while ( walker )
{
const gchar * key_data = (const gchar *)keys->data;
const gchar * key_data = (const gchar *)walker->data;
args = g_list_append(args, g_strdup(key_data));
args = g_list_append(args, g_strdup((const gchar *)g_hash_table_lookup(arguments, key_data)));
keys = g_list_next(keys);
walker = g_list_next(walker);
}
g_list_free(keys);
}
extcap_run_one(interface, args, cb_reload_preference, &ret, NULL);