Skip to content

Commit

Permalink
extcap: remove leak in interface lists.
Browse files Browse the repository at this point in the history
Change-Id: Ib57292afc88cd32736b78a901385cfdde84c46c9
Reviewed-on: https://code.wireshark.org/review/20297
Reviewed-by: Roland Knall <rknall@gmail.com>
Petri-Dish: Roland Knall <rknall@gmail.com>
Reviewed-by: Dario Lombardo <lomato@gmail.com>
  • Loading branch information
crondaemon committed Feb 27, 2017
1 parent a29fe9d commit 8851c1c
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions extcap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1337,11 +1337,20 @@ extcap_ensure_interface(const gchar * toolname)
return element;
}

static void remove_extcap_entry(gpointer entry, gpointer data _U_)
{
extcap_interface *int_iter = (extcap_interface*)entry;

if (int_iter->if_type == EXTCAP_SENTENCE_EXTCAP)
g_free(int_iter);
}

static gboolean cb_load_interfaces(const gchar *extcap, const gchar *ifname _U_, gchar *output _U_, void *data _U_,
char **err_str _U_)
{
GList *interfaces = NULL, *walker = NULL;
extcap_interface *int_iter = NULL;
gchar *toolname = g_path_get_basename(extcap);

GList * interface_keys = g_hash_table_get_keys(_loaded_interfaces);

Expand All @@ -1355,12 +1364,11 @@ static gboolean cb_load_interfaces(const gchar *extcap, const gchar *ifname _U_,
{
int_iter = (extcap_interface *)walker->data;

gchar * toolname = g_path_get_basename(extcap);
extcap_info * element = extcap_ensure_interface(toolname);

if ( element == NULL )
{
g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_ERROR, "Cannot store interface %s", extcap );
g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_ERROR, "Cannot store interface %s", extcap);
walker = g_list_next(walker);
continue;
}
Expand Down Expand Up @@ -1416,6 +1424,10 @@ static gboolean cb_load_interfaces(const gchar *extcap, const gchar *ifname _U_,
walker = g_list_next(walker);
}

g_list_foreach(interfaces, remove_extcap_entry, NULL);
g_list_free(interfaces);
g_list_free(interface_keys);
g_free(toolname);
return TRUE;
}

Expand Down

0 comments on commit 8851c1c

Please sign in to comment.