aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDario Lombardo <lomato@gmail.com>2019-12-08 18:33:45 +0100
committerTomasz Moń <desowin@gmail.com>2019-12-15 12:23:49 +0000
commit1cd1e36a05bd0f14b38ce3978e3313d57b3b25d4 (patch)
tree6649bfc8a50677cbf98771bbcfa9e9e0374c57fd
parenteffe6ddacabad5a9bf08eaf0bb910bbe44813b03 (diff)
extcap: remove potential leak.
Found by clang. Change-Id: I84359a2f7985bca8b0089200b3c37d04e06effe2 Reviewed-on: https://code.wireshark.org/review/35354 Petri-Dish: Tomasz Moń <desowin@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Tomasz Moń <desowin@gmail.com>
-rw-r--r--extcap.c14
1 files 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);