diff options
author | Pascal Quantin <pascal.quantin@gmail.com> | 2017-03-27 21:19:28 +0200 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2017-03-28 05:05:13 +0000 |
commit | cabd7d82935561dde001ba7132ae145ea2c6dbeb (patch) | |
tree | 89c246215ef97c72b47dc018d01bbab89cedf0ac /wsutil | |
parent | 2141eafa64fd080b1aeb0aa2259c57de076c8836 (diff) |
wsutil: fix a NULL pointer dereference when there is a single plugin registered
Rework loop to avoid dereferencing a NULL pointer. Bug introduced in g6d79055
Change-Id: I88a9f2d045b633cc2365ff6ce939f3315e7d42cc
Reviewed-on: https://code.wireshark.org/review/20751
Reviewed-by: Michael Mann <mmann78@netscape.net>
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'wsutil')
-rw-r--r-- | wsutil/plugins.c | 22 |
1 files changed, 6 insertions, 16 deletions
diff --git a/wsutil/plugins.c b/wsutil/plugins.c index d916c9cf77..d726e80c1e 100644 --- a/wsutil/plugins.c +++ b/wsutil/plugins.c @@ -435,22 +435,12 @@ free_plugin_type(gpointer p, gpointer user_data _U_) void plugins_cleanup(void) { - plugin* prev; - plugin* cur; - - if (plugin_list) { - prev = plugin_list; - cur = plugin_list->next; - - do { - g_free(prev->name); - g_free(prev); - prev = cur; - cur = cur->next; - } while(cur); - - g_free(prev->name); - g_free(prev); + plugin* cur, *next; + + for (cur = plugin_list; cur != NULL; cur = next) { + next = cur->next; + g_free(cur->name); + g_free(cur); } g_slist_foreach(plugin_types, free_plugin_type, NULL); |