wtap: fix leak in optionblock management.
Found by valgrind: ==14298== at 0x4C2CE8E: realloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==14298== by 0xA66C6AE: g_realloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4002.0) ==14298== by 0xA63BB32: ??? (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4002.0) ==14298== by 0xA63BEB7: g_array_append_vals (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4002.0) ==14298== by 0xA193252: wtap_optionblock_add_option (wtap_opttypes.c:352) ==14298== by 0xA19361C: shb_create (wtap_opttypes.c:607) ==14298== by 0xA192F96: wtap_optionblock_create (wtap_opttypes.c:126) ==14298== by 0xA168784: wtap_open_offline (file_access.c:824) ==14298== by 0x11D47C: cf_open (tshark.c:4194) ==14298== by 0x117852: main (tshark.c:2183) et al. Change-Id: Ic16595ed3c12b9ed6c2813852ceb594c29ece929 Reviewed-on: https://code.wireshark.org/review/15004 Petri-Dish: Dario Lombardo <lomato@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Evan Huus <eapache@gmail.com> Reviewed-by: Michael Mann <mmann78@netscape.net>
This commit is contained in:
parent
45a4ec8ae8
commit
c33274dafa
|
@ -155,6 +155,7 @@ static void wtap_optionblock_free_options(wtap_optionblock_t block)
|
|||
|
||||
void wtap_optionblock_free(wtap_optionblock_t block)
|
||||
{
|
||||
unsigned i;
|
||||
if (block != NULL)
|
||||
{
|
||||
if (block->info->free_mand != NULL)
|
||||
|
@ -162,10 +163,12 @@ void wtap_optionblock_free(wtap_optionblock_t block)
|
|||
|
||||
g_free(block->mandatory_data);
|
||||
wtap_optionblock_free_options(block);
|
||||
for (i = 0; i < block->option_infos->len; i++)
|
||||
g_free(g_array_index(block->option_infos, wtap_optblock_internal_t*, i));
|
||||
if (block->option_infos != NULL)
|
||||
g_array_free(block->option_infos, FALSE);
|
||||
g_array_free(block->option_infos, TRUE);
|
||||
if (block->option_values != NULL)
|
||||
g_array_free(block->option_values, FALSE);
|
||||
g_array_free(block->option_values, TRUE);
|
||||
g_free(block);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue