aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap/file_access.c
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2019-01-24 00:15:08 +0100
committerAnders Broman <a.broman58@gmail.com>2019-01-24 04:21:23 +0000
commit9d5ab211635e201692cc250732be50a234e03d1c (patch)
tree60fdeabff3c71f4196b7d62cd1c59c23f4fdf1aa /wiretap/file_access.c
parent9175a235a8d8b77a9734b757274129ef0f3d3e84 (diff)
wiretap: fix leak of options_buf and document memory handling
Manually checked all callers of wtap_seek_read to ensure that wtap_rec_cleanup is called. Added missing wtap_rec_cleanup to: - Completion of sequential read: wtap_sequential_close - Callers of wtap_seek_read: - users of cf_read_record_r: - PacketListRecord::dissect This fixes one of the two ASAN memleak reports while running test_tshark_z_expert_comment and test_text2pcap_sip_pcapng (the other is about opt_comment which is still unfixed). Vasil Velichkov also found this issue and came up with a similar fix. Change-Id: I54a6aa70bfdb42a816d03ad4861d0ad821d0ef88 Reviewed-on: https://code.wireshark.org/review/31709 Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'wiretap/file_access.c')
-rw-r--r--wiretap/file_access.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/wiretap/file_access.c b/wiretap/file_access.c
index 894da7b085..803dac8d0b 100644
--- a/wiretap/file_access.c
+++ b/wiretap/file_access.c
@@ -1128,7 +1128,9 @@ fail:
return NULL;
success:
- wth->rec_data = (struct Buffer *)g_malloc(sizeof(struct Buffer));
+ /* wth->rec_data is used for the sequential read and will be freed by
+ * wtap_sequential_close (which is also called by wtap_close). */
+ wth->rec_data = g_new(struct Buffer, 1);
ws_buffer_init(wth->rec_data, 1500);
if ((wth->file_type_subtype == WTAP_FILE_TYPE_SUBTYPE_PCAP) ||