diff options
author | Michael Mann <mmann78@netscape.net> | 2015-01-11 19:48:54 -0500 |
---|---|---|
committer | Michael Mann <mmann78@netscape.net> | 2015-01-16 00:37:02 +0000 |
commit | e530c899406d2212fb7cb8821d083fb4871ff718 (patch) | |
tree | 9bb1ef43a4ed562dfb7a19c4db4ecd17926801a7 /ui/cli | |
parent | 7d43836b3ad54073a98926450ff0bca7bc34ddeb (diff) |
Replace se alloced memory in compare stat tap.
Also replaced comments mentioning se_alloc memory with wmem_file_scope, since it's more accurate.
It seems that many of the TShark stat taps may be leaking memory, because the hash tables created by the taps don't get a chance to be freed. Somewhat academic since TShark exits shortly after displaying any stats, but a leak none the less.
Change-Id: I8ceecbd00d65b3442dc02d720b39c2e15aa0c8a6
Reviewed-on: https://code.wireshark.org/review/6557
Reviewed-by: Evan Huus <eapache@gmail.com>
Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'ui/cli')
-rw-r--r-- | ui/cli/tap-comparestat.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/ui/cli/tap-comparestat.c b/ui/cli/tap-comparestat.c index a8b73a6979..3d85d4ff09 100644 --- a/ui/cli/tap-comparestat.c +++ b/ui/cli/tap-comparestat.c @@ -135,8 +135,8 @@ comparestat_packet(void *arg, packet_info *pinfo, epan_dissect_t *edt _U_, const computed_cksum = in_cksum(&cksum_vec[0], 3); /* collect all packet infos */ - fInfo = (frame_info*)se_alloc(sizeof(frame_info)); - fInfo->fp = (for_print*)se_alloc(sizeof(for_print)); + fInfo = (frame_info*)g_malloc(sizeof(frame_info)); + fInfo->fp = (for_print*)g_malloc(sizeof(for_print)); fInfo->fp->partner = NULL; fInfo->fp->count = 1; fInfo->fp->cksum = computed_cksum; @@ -153,6 +153,16 @@ comparestat_packet(void *arg, packet_info *pinfo, epan_dissect_t *edt _U_, const return 1; } + +static void +frame_info_free(gpointer data) +{ + frame_info *fInfo = (frame_info *)data; + + g_free(fInfo->fp); + g_free(fInfo); +} + /* Find equal packets, same IP-Id, count them and make time statistics */ static void call_foreach_count_ip_id(gpointer key _U_, gpointer value, gpointer arg) @@ -549,7 +559,7 @@ 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->packet_set = g_hash_table_new_full(NULL, NULL, NULL, frame_info_free); error_string = register_tap_listener("ip", cs, filter, 0, comparestat_reset, comparestat_packet, comparestat_draw); if (error_string) { |