summaryrefslogtreecommitdiff
path: root/extcap/extcap-base.c
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2016-03-28 17:50:28 +0200
committerRoland Knall <rknall@gmail.com>2016-03-29 06:01:31 +0000
commit0aa0fb25e048c1d9abca03a8a1681b99ddcc7410 (patch)
tree9ff3e8bada67da033c6d1e6c839d845af696474b /extcap/extcap-base.c
parent24768a7147b27daba28e2e88c333f0826724fe80 (diff)
downloadwireshark-0aa0fb25e048c1d9abca03a8a1681b99ddcc7410.tar.gz
Another round of extcap memleak fixes
Fix a bunch of memory leaks, mainly because extcap_base_cleanup is not called on most execution paths and because memory allocated for options were not freed. Additionally, randpkt will now fail if no option is given (it previously returned 0 if --capture was missing). Logic using "goto" is introduced with the idea that a program should fail (ret = EXIT_FAILURE) unless proven otherwise. Now none of the extcap programs are leaking: for what in ssh cisco; do for arg in '' --help --extcap-interfaces --extcap-interface=$what; do extcap/${what}dump $arg; done; done ./tshark -D Change-Id: I6df1027ed0c32bd53fe87e6c54d355bc8ddd01f5 Reviewed-on: https://code.wireshark.org/review/14671 Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Roland Knall <rknall@gmail.com>
Diffstat (limited to 'extcap/extcap-base.c')
-rw-r--r--extcap/extcap-base.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/extcap/extcap-base.c b/extcap/extcap-base.c
index 17bf227f25..b31be5b44e 100644
--- a/extcap/extcap-base.c
+++ b/extcap/extcap-base.c
@@ -108,11 +108,13 @@ void extcap_base_register_interface_ext(extcap_parameters * extcap,
const char * interface, const char * ifdescription,
uint16_t dlt, const char * dltname, const char * dltdescription )
{
- extcap_interface * iface = g_new0(extcap_interface, 1);
+ extcap_interface * iface;
if (interface == NULL)
return;
+ iface = g_new0(extcap_interface, 1);
+
iface->interface = g_strdup(interface);
iface->description = g_strdup(ifdescription);
iface->dlt = dlt;
@@ -251,6 +253,7 @@ static void extcap_iface_free(gpointer data)
g_free(iface->description);
g_free(iface->dltname);
g_free(iface->dltdescription);
+ g_free(iface);
}
void extcap_base_cleanup(extcap_parameters ** extcap)