diff options
author | Peter Wu <peter@lekensteyn.nl> | 2019-01-25 17:04:33 +0100 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2019-01-26 07:42:17 +0000 |
commit | 0b632861e21222513fac38487a56e442a4aac2fb (patch) | |
tree | 26b76a0bec4ab15dd7f34c0ae222ae0faf8e9853 /ringbuffer.c | |
parent | 728183c27e778ada5a329a55353b09a83d11ceac (diff) |
dumpcap: fix memory leak in ringbuffer mode
'save_file' is used both for holding the -w command-line argument as
well as the current filename that is being written. In ringbuffer mode,
the former is already freed while the latter changes after rotation. Be
sure to free all ringbuffer filenames on exit.
Fixes test failures due to ASAN reporting memory leaks for:
test_dumpcap_ringbuffer_filesize
test_dumpcap_pcapng_single_in_multi_out
test_dumpcap_pcapng_multi_in_multi_out
test_dumpcap_ringbuffer_packets
Change-Id: Ib817d8340275d7afa7e149dcfbbc59ed78293c34
Reviewed-on: https://code.wireshark.org/review/31739
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'ringbuffer.c')
-rw-r--r-- | ringbuffer.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/ringbuffer.c b/ringbuffer.c index 31eb9bdd33..b84c032086 100644 --- a/ringbuffer.c +++ b/ringbuffer.c @@ -203,8 +203,18 @@ ringbuf_init(const char *capfile_name, guint num_files, gboolean group_read_acce } +/* + * Whether the ringbuf filenames are ready. + * (Whether ringbuf_init is called and ringbuf_free is not called.) + */ +gboolean ringbuf_is_initialized(void) +{ + return rb_data.files != NULL; +} + const gchar *ringbuf_current_filename(void) { + /* g_assert(ringbuf_is_initialized()); */ return rb_data.files[rb_data.curr_file_num % rb_data.num_files].name; } @@ -359,7 +369,7 @@ ringbuf_error_cleanup(void) #endif /* HAVE_LIBPCAP */ /* - * Editor modelines - http://www.wireshark.org/tools/modelines.html + * Editor modelines - https://www.wireshark.org/tools/modelines.html * * Local Variables: * c-basic-offset: 2 |