From cabd7d82935561dde001ba7132ae145ea2c6dbeb Mon Sep 17 00:00:00 2001 From: Pascal Quantin Date: Mon, 27 Mar 2017 21:19:28 +0200 Subject: 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 Petri-Dish: Michael Mann Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman --- wsutil/plugins.c | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) (limited to 'wsutil') 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); -- cgit v1.2.1