wiretap: fix memory leak of interface_data for wtap_dumper

Mirrors the behavior of wtap_close.

Change-Id: I1a04878fdd0409fa74931737332f9b8a1ae77fb1
Reviewed-on: https://code.wireshark.org/review/17620
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
This commit is contained in:
Peter Wu 2016-09-10 01:12:58 +02:00
parent d6f91a7ca4
commit ba2a3b3626
2 changed files with 12 additions and 3 deletions

View File

@ -2204,7 +2204,8 @@ wtap_dump_init_dumper(int file_type_subtype, int encap, int snaplen, gboolean co
if ((idb_inf != NULL) && (idb_inf->interface_data->len > 0)) {
guint itf_count;
/* XXX: what free's this stuff? */
/* Note: this memory is owned by wtap_dumper and will become
* invalid after wtap_dump_close. */
wdh->interface_data = g_array_new(FALSE, FALSE, sizeof(wtap_block_t));
for (itf_count = 0; itf_count < idb_inf->interface_data->len; itf_count++) {
file_int_data = g_array_index(idb_inf->interface_data, wtap_block_t, itf_count);
@ -2574,6 +2575,7 @@ wtap_dump_close(wtap_dumper *wdh, int *err)
}
if (wdh->priv != NULL)
g_free(wdh->priv);
wtap_block_array_free(wdh->interface_data);
g_free(wdh);
return ret;
}

View File

@ -1713,9 +1713,11 @@ void wtap_fdclose(wtap *wth);
WS_DLL_PUBLIC
gboolean wtap_fdreopen(wtap *wth, const char *filename, int *err);
/*** close the current file ***/
/** Close only the sequential side, freeing up memory it uses. */
WS_DLL_PUBLIC
void wtap_sequential_close(wtap *wth);
/** Closes any open file handles and frees the memory associated with wth. */
WS_DLL_PUBLIC
void wtap_close(wtap *wth);
@ -1874,8 +1876,13 @@ void wtap_set_bytes_dumped(wtap_dumper *wdh, gint64 bytes_dumped);
struct addrinfo;
WS_DLL_PUBLIC
gboolean wtap_dump_set_addrinfo_list(wtap_dumper *wdh, addrinfo_lists_t *addrinfo_lists);
/**
* Closes open file handles and frees memory associated with wdh. Note that
* shb_hdr, idb_inf and nrb_hdr are not freed by this routine.
*/
WS_DLL_PUBLIC
gboolean wtap_dump_close(wtap_dumper *, int *);
gboolean wtap_dump_close(wtap_dumper *wdh, int *err);
/**
* Return TRUE if we can write a file out with the given GArray of file