From ce246a6b64540d18f61e396df639213914c2421b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Valverde?= Date: Tue, 18 Aug 2015 08:11:34 +0100 Subject: [GTK] Fix crash in comparestat.c Selecting a row in the statistics table causes a Glib assertion failure. GLib:ERROR:ghash.c:373:g_hash_table_lookup_node: assertion failed: (hash_table->ref_count > 0) When the comparestat_draw() function is called, the cs->ip_id_set hash table is created and then immediately destroyed, but the hash table lookup to cs->ip_id_set in new_tree_view_selection_changed() can happen anytime the user clicks on a table row. Bug: 11098 Change-Id: I6c7a39c947ca11327c3fc3ab0d4caa735798d142 Reviewed-on: https://code.wireshark.org/review/10096 Petri-Dish: Michael Mann Tested-by: Petri Dish Buildbot Reviewed-by: Michael Mann (cherry picked from commit 9c331f73b5be7cde6b04b6cb68cf73deb4bdc4ce) Reviewed-on: https://code.wireshark.org/review/10193 Reviewed-by: Anders Broman --- ui/gtk/compare_stat.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ui/gtk/compare_stat.c b/ui/gtk/compare_stat.c index 3b70075b3a..e3ed636278 100644 --- a/ui/gtk/compare_stat.c +++ b/ui/gtk/compare_stat.c @@ -524,6 +524,7 @@ win_destroy_cb(GtkWindow *win _U_, gpointer data) gtk_tree_store_clear(cs->simple_list); g_hash_table_destroy(cs->packet_set); g_hash_table_destroy(cs->nr_set); + g_hash_table_destroy(cs->ip_id_set); g_free(cs); } @@ -563,7 +564,6 @@ comparestat_draw(void *arg) return; } - cs->ip_id_set=g_hash_table_new(NULL, NULL); g_hash_table_foreach(cs->packet_set, call_foreach_count_ip_id, cs); /* set up TTL choice if only one number found */ @@ -616,7 +616,6 @@ comparestat_draw(void *arg) } g_hash_table_foreach(cs->ip_id_set, call_foreach_print_ip_tree, cs); - g_hash_table_destroy(cs->ip_id_set); g_string_free(filter_str, TRUE); g_array_free(cs->ip_ttl_list, TRUE); } @@ -792,12 +791,15 @@ gtk_comparestat_init(const char *opt_arg, void* userdata _U_) /* create a Hash to count the packets with the same ip.id */ cs->packet_set=g_hash_table_new(NULL, NULL); + cs->ip_id_set=g_hash_table_new(NULL, NULL); + error_string=register_tap_listener("ip", cs, filter, 0, comparestat_reset, comparestat_packet, comparestat_draw); if(error_string){ simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", error_string->str); g_string_free(error_string, TRUE); gtk_tree_store_clear(cs->simple_list); g_hash_table_destroy(cs->packet_set); + g_hash_table_destroy(cs->ip_id_set); g_free(cs); return; } -- cgit v1.2.1