diff options
author | Evan Huus <eapache@gmail.com> | 2014-04-30 00:02:40 -0400 |
---|---|---|
committer | Evan Huus <eapache@gmail.com> | 2014-04-30 11:59:39 +0000 |
commit | abe7f7da5402a2d0f1f3f467b28b8ab3706ebf36 (patch) | |
tree | d774e7be2c581db66d41cbcf700349852b05005c /epan/dissectors/packet-spdy.c | |
parent | 9cdba462512cdd8c6910ce9671282a7a0cd5dee3 (diff) |
Cleanup libz streams in SPDY dissector
Fixes major memory leak.
Bug:10062
Change-Id: Ife70f12b8697a7873860c702ee0c740f98d98821
Reviewed-on: https://code.wireshark.org/review/1435
Reviewed-by: Evan Huus <eapache@gmail.com>
Diffstat (limited to 'epan/dissectors/packet-spdy.c')
-rw-r--r-- | epan/dissectors/packet-spdy.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/epan/dissectors/packet-spdy.c b/epan/dissectors/packet-spdy.c index 72e57cc3d5..c8204f18d3 100644 --- a/epan/dissectors/packet-spdy.c +++ b/epan/dissectors/packet-spdy.c @@ -439,6 +439,20 @@ static const char spdy_dictionary[] = { 0x2c, 0x65, 0x6e, 0x71, 0x3d, 0x30, 0x2e /* - e n q - 0 - */ }; +#ifdef HAVE_LIBZ +/* callback function used at the end of file-scope to cleanup zlib's inflate + * streams to avoid memory leaks. + * XXX: can we be more aggressive and call this sooner for finished streams? + */ +static gboolean inflate_end_cb (wmem_allocator_t *allocator _U_, + wmem_cb_event_t event _U_, void *user_data) { + + inflateEnd((z_streamp)user_data); + + return FALSE; +} +#endif + /* * Returns conversation data for a given packet. If conversation data can't be * found, creates and returns new conversation data. @@ -465,7 +479,13 @@ static spdy_conv_t * get_or_create_spdy_conversation_data(packet_info *pinfo) { conv_data->rply_decompressor = (z_streamp)wmem_alloc0(wmem_file_scope(), sizeof(z_stream)); retcode = inflateInit(conv_data->rqst_decompressor); if (retcode == Z_OK) { - inflateInit(conv_data->rply_decompressor); + wmem_register_callback(wmem_file_scope(), inflate_end_cb, + conv_data->rqst_decompressor); + retcode = inflateInit(conv_data->rply_decompressor); + if (retcode == Z_OK) { + wmem_register_callback(wmem_file_scope(), inflate_end_cb, + conv_data->rply_decompressor); + } } /* XXX - use wsutil/adler32.h? */ |