aboutsummaryrefslogtreecommitdiffstats
path: root/editcap.c
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2016-09-10 01:20:41 +0200
committerPeter Wu <peter@lekensteyn.nl>2016-09-10 13:00:05 +0000
commitd1a82132a62bbd5c20e0490c6f7d693c318481d1 (patch)
tree8243b7720175e00cfa7056843a07f0a8c0656017 /editcap.c
parentba2a3b3626ef9fc084ee8a9508d196ec890c2336 (diff)
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 <peter@lekensteyn.nl>
Diffstat (limited to 'editcap.c')
-rw-r--r--editcap.c16
1 files changed, 9 insertions, 7 deletions
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: