From d1a82132a62bbd5c20e0490c6f7d693c318481d1 Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Sat, 10 Sep 2016 01:20:41 +0200 Subject: editcap: fix memleaks The version string stuff mirrors an earlier tshark change. Move some cleanup calls (in case no packets are selected) and add wtap_close. Change-Id: I6f282e89279a732c226824e10857be04b40841e8 Reviewed-on: https://code.wireshark.org/review/17621 Reviewed-by: Peter Wu --- editcap.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'editcap.c') diff --git a/editcap.c b/editcap.c index 6fce55dbfe..7fb1b8cb41 100644 --- a/editcap.c +++ b/editcap.c @@ -1006,6 +1006,8 @@ main(int argc, char *argv[]) "\n" "%s", get_ws_vcs_version_info(), comp_info_str->str, runtime_info_str->str); + g_string_free(comp_info_str, TRUE); + g_string_free(runtime_info_str, TRUE); /* * Get credential information for later use. @@ -1237,6 +1239,8 @@ main(int argc, char *argv[]) break; case 'V': + comp_info_str = get_compiled_version_info(NULL, NULL); + runtime_info_str = get_runtime_version_info(NULL); show_version("Editcap (Wireshark)", comp_info_str, runtime_info_str); g_string_free(comp_info_str, TRUE); g_string_free(runtime_info_str, TRUE); @@ -1822,18 +1826,11 @@ main(int argc, char *argv[]) } } - g_free(idb_inf); - idb_inf = NULL; - if (!wtap_dump_close(pdh, &write_err)) { fprintf(stderr, "editcap: Error writing to %s: %s\n", filename, wtap_strerror(write_err)); goto error_on_exit; } - wtap_block_array_free(shb_hdrs); - shb_hdrs = NULL; - wtap_block_array_free(nrb_hdrs); - nrb_hdrs = NULL; g_free(filename); if (frames_user_comments) { @@ -1853,6 +1850,11 @@ main(int argc, char *argv[]) (long int)relative_time_window.nsecs); } + wtap_block_array_free(shb_hdrs); + wtap_block_array_free(nrb_hdrs); + g_free(idb_inf); + wtap_close(wth); + return 0; error_on_exit: -- cgit v1.2.1