From e803f83ac8f6f55247ce99a57bbfa8633019e4d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Mo=C5=84?= Date: Sat, 18 May 2019 10:01:37 +0200 Subject: [PATCH] extcap: Fix memory leak in extcap_has_toolbar() The content of the list returned by g_hash_table_get_values() is owned by GHashTable and should not be modified or freed. However, the list itself should be freed using g_list_free(). Use g_strcmp0() to compare keys instead of strcmp() as it handles NULL gracefully. Change-Id: I8f5d70ffc2cd6eb5001b5086e4e31256b65431c7 Reviewed-on: https://code.wireshark.org/review/33246 Petri-Dish: Alexis La Goutte Tested-by: Petri Dish Buildbot Reviewed-by: Peter Wu --- extcap.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/extcap.c b/extcap.c index 64c44a8413..5fd5ffacb3 100644 --- a/extcap.c +++ b/extcap.c @@ -1151,12 +1151,14 @@ extcap_has_toolbar(const char *ifname) for (GList *walker = toolbar_list; walker; walker = walker->next) { iface_toolbar *toolbar = (iface_toolbar *) walker->data; - if (g_list_find_custom(toolbar->ifnames, ifname, (GCompareFunc) strcmp)) + if (g_list_find_custom(toolbar->ifnames, ifname, (GCompareFunc) g_strcmp0)) { + g_list_free(toolbar_list); return TRUE; } } + g_list_free(toolbar_list); return FALSE; }