diff options
author | David Perry <boolean263@protonmail.com> | 2021-08-04 13:18:46 -0400 |
---|---|---|
committer | Guy Harris <gharris@sonic.net> | 2021-08-10 00:08:15 +0000 |
commit | 6e12643f198500245ee6eff999804e468481a7b3 (patch) | |
tree | 0d08844a58e4cf465b1d13ecf70a736a5e772105 /editcap.c | |
parent | 4aee4059745f6089e530344289e7ea24d5ec2db4 (diff) |
[#17478] free blocks in more places
Bug 17478 was caused by `wtap_rec.block` being allocated for each
packet, but not freed when it was done being used -- typically at the
end of a loop.
Rather than requiring each caller of `wtap_read()` to know to free a
member of `rec`, I added a new function `wtap_rec_reset()` for a
slightly cleaner API. Added calls to it everywhere that seemed to make
sense.
Fixes #17478
Diffstat (limited to 'editcap.c')
-rw-r--r-- | editcap.c | 3 |
1 files changed, 3 insertions, 0 deletions
@@ -1155,6 +1155,7 @@ main(int argc, char *argv[]) unsigned int seed = 0; cmdarg_err_init(editcap_cmdarg_err, editcap_cmdarg_err_cont); + memset(&read_rec, 0, sizeof *rec); /* Initialize log handler early so we can have proper logging during startup. */ ws_log_init("editcap", vcmdarg_err); @@ -2216,6 +2217,7 @@ main(int argc, char *argv[]) written_count++; } count++; + wtap_rec_reset(&read_rec); } wtap_rec_cleanup(&read_rec); ws_buffer_free(&read_buf); @@ -2285,6 +2287,7 @@ clean_exit: wtap_dump_params_cleanup(¶ms); if (wth != NULL) wtap_close(wth); + wtap_rec_reset(&read_rec); wtap_cleanup(); free_progdirs(); if (capture_comments != NULL) { |