From 1cd1e36a05bd0f14b38ce3978e3313d57b3b25d4 Mon Sep 17 00:00:00 2001 From: Dario Lombardo Date: Sun, 8 Dec 2019 18:33:45 +0100 Subject: extcap: remove potential leak. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Found by clang. Change-Id: I84359a2f7985bca8b0089200b3c37d04e06effe2 Reviewed-on: https://code.wireshark.org/review/35354 Petri-Dish: Tomasz Moń Tested-by: Petri Dish Buildbot Reviewed-by: Tomasz Moń --- extcap.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/extcap.c b/extcap.c index d371b5ef52..d0e078ffb5 100644 --- a/extcap.c +++ b/extcap.c @@ -320,14 +320,15 @@ extcap_if_executable(const gchar *ifname) return interface != NULL ? interface->extcap_path : NULL; } -static void +static gboolean extcap_iface_toolbar_add(const gchar *extcap, iface_toolbar *toolbar_entry) { char *toolname; + gboolean ret = FALSE; if (!extcap || !toolbar_entry) { - return; + return ret; } toolname = g_path_get_basename(extcap); @@ -335,9 +336,11 @@ extcap_iface_toolbar_add(const gchar *extcap, iface_toolbar *toolbar_entry) if (!g_hash_table_lookup(_toolbars, toolname)) { g_hash_table_insert(_toolbars, g_strdup(toolname), toolbar_entry); + ret = TRUE; } g_free(toolname); + return ret; } static gchar ** @@ -1863,9 +1866,14 @@ process_new_extcap(const char *extcap, char *output) if (toolbar_entry && toolbar_entry->menu_title) { iface_toolbar_add(toolbar_entry); - extcap_iface_toolbar_add(extcap, toolbar_entry); + if (!extcap_iface_toolbar_add(extcap, toolbar_entry)) + { + extcap_free_toolbar(toolbar_entry); + toolbar_entry = NULL; + } } + extcap_free_toolbar(toolbar_entry); g_list_foreach(interfaces, remove_extcap_entry, NULL); g_list_free(interfaces); g_list_free(interface_keys); -- cgit v1.2.3