[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 <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
This commit is contained in:
João Valverde 2015-08-18 08:11:34 +01:00 committed by Michael Mann
parent 0d61321f69
commit 9c331f73b5
1 changed files with 4 additions and 2 deletions

View File

@ -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);
}
@ -564,7 +565,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 */
@ -617,7 +617,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);
}
@ -791,12 +790,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_full(NULL, NULL, NULL, frame_info_free);
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;
}