Skip to content

Commit

Permalink
funnel: Fix memleaks in funnel_remove_menu
Browse files Browse the repository at this point in the history
The loop to remove all matching callbacks was skipping every second
entry which would give some leaks when reloading Lua plugins.

Add funnel_cleanup() to be called in epan_cleanup() at shutdown
to remove all allocated menu entries.

Change-Id: I3a50ba2070c8675fee1385f25e9e109db57c2dc5
Reviewed-on: https://code.wireshark.org/review/31769
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
  • Loading branch information
stigbjorlykke committed Jan 28, 2019
1 parent 5b22624 commit 6cab8c5
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions debian/libwireshark0.symbols
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,7 @@ libwireshark.so.0 libwireshark0 #MINVER#
ftype_can_slice@Base 1.9.1
ftype_name@Base 1.9.1
ftype_pretty_name@Base 1.9.1
funnel_cleanup@Base 2.9.1
funnel_get_funnel_ops@Base 1.9.1
funnel_register_all_menus@Base 1.9.1
funnel_register_menu@Base 1.9.1
Expand Down
1 change: 1 addition & 0 deletions epan/epan.c
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ epan_cleanup(void)
export_pdu_cleanup();
cleanup_enabled_and_disabled_lists();
stats_tree_cleanup();
funnel_cleanup();
dtd_location(NULL);
#ifdef HAVE_LUA
wslua_cleanup();
Expand Down
7 changes: 6 additions & 1 deletion epan/funnel.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ static void funnel_remove_menu (funnel_menu_t ** menu_list, funnel_menu_t *menu)
if (p) {
m = p->next;
} else {
m = *menu_list ? (*menu_list)->next : NULL;
m = *menu_list;
}
} else {
p = m;
Expand Down Expand Up @@ -139,6 +139,11 @@ void funnel_reload_menus(funnel_deregistration_cb_t d_cb,
funnel_clear_menu(&added_menus);
}

void funnel_cleanup(void)
{
funnel_clear_menu(&registered_menus);
}

/*
* Editor modelines - http://www.wireshark.org/tools/modelines.html
*
Expand Down
1 change: 1 addition & 0 deletions epan/funnel.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ typedef void (*funnel_deregistration_cb_t)(funnel_menu_callback callback);
WS_DLL_PUBLIC void funnel_register_all_menus(funnel_registration_cb_t r_cb);
WS_DLL_PUBLIC void funnel_reload_menus(funnel_deregistration_cb_t d_cb,
funnel_registration_cb_t r_cb);
WS_DLL_PUBLIC void funnel_cleanup(void);

extern void initialize_funnel_ops(void);

Expand Down

0 comments on commit 6cab8c5

Please sign in to comment.