aboutsummaryrefslogtreecommitdiffstats
path: root/epan/proto.c
diff options
context:
space:
mode:
authorKovarththanan Rajaratnam <kovarththanan.rajaratnam@gmail.com>2009-09-01 18:16:55 +0000
committerKovarththanan Rajaratnam <kovarththanan.rajaratnam@gmail.com>2009-09-01 18:16:55 +0000
commit17f010119acebd1ae599d44b3456bbb7b1c63ab2 (patch)
treef5f8a91956fb8ac09d9b4958ffa2f12729495caf /epan/proto.c
parent95bf5607278eb0a10a12f5d69af2bf27c5fd56a3 (diff)
downloadwireshark-17f010119acebd1ae599d44b3456bbb7b1c63ab2.tar.gz
wireshark-17f010119acebd1ae599d44b3456bbb7b1c63ab2.tar.bz2
wireshark-17f010119acebd1ae599d44b3456bbb7b1c63ab2.zip
From Jakub Zawadzki via. Bug 3330:
* Fix memleak (df->deprecated in dfilter_free()) * Free protocol hash tables on cleanup. * Free protocols list on cleanup. * Free memory allocated by fgetline() in parse_services_file() From me: * proto.c: set gmc_hfinfo to NULL after free * proto.c: switch order of g_free() and g_list_remove() in proto_cleanup() svn path=/trunk/; revision=29656
Diffstat (limited to 'epan/proto.c')
-rw-r--r--epan/proto.c32
1 files changed, 28 insertions, 4 deletions
diff --git a/epan/proto.c b/epan/proto.c
index c4480ad2ac..b9913a99a6 100644
--- a/epan/proto.c
+++ b/epan/proto.c
@@ -325,13 +325,12 @@ proto_init(void (register_all_protocols_func)(register_cb cb, gpointer client_da
NULL, HFILL }},
};
+ proto_cleanup();
- proto_names = g_hash_table_new(g_int_hash, g_int_equal);
+ proto_names = g_hash_table_new_full(g_int_hash, g_int_equal, g_free, NULL);
proto_short_names = g_hash_table_new(wrs_str_hash, g_str_equal);
proto_filter_names = g_hash_table_new(wrs_str_hash, g_str_equal);
- proto_cleanup();
-
gmc_hfinfo = g_mem_chunk_new("gmc_hfinfo",
sizeof(header_field_info),
INITIAL_NUM_PROTOCOL_HFINFO * sizeof(header_field_info),
@@ -405,8 +404,33 @@ proto_cleanup(void)
gpa_name_tree = NULL;
}
- if (gmc_hfinfo)
+ while (protocols) {
+ protocol_t *protocol = protocols->data;
+
+ g_list_free(protocol->fields);
+ protocols = g_list_remove(protocols, protocol);
+ g_free(protocol);
+ }
+
+ if (proto_names) {
+ g_hash_table_destroy(proto_names);
+ proto_names = NULL;
+ }
+
+ if (proto_short_names) {
+ g_hash_table_destroy(proto_short_names);
+ proto_short_names = NULL;
+ }
+
+ if (proto_filter_names) {
+ g_hash_table_destroy(proto_filter_names);
+ proto_filter_names = NULL;
+ }
+
+ if (gmc_hfinfo) {
g_mem_chunk_destroy(gmc_hfinfo);
+ gmc_hfinfo = NULL;
+ }
if(gpa_hfinfo.allocated_len){
gpa_hfinfo.len=0;