aboutsummaryrefslogtreecommitdiff
path: root/pcap-linux.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2015-05-04 10:55:35 -0700
committerGuy Harris <guy@alum.mit.edu>2015-05-04 10:55:35 -0700
commitcd46a74cf49299d92640bfe63b4caf66e0cce65c (patch)
treee9f5a9cab42c1b5c541590efa5d74533101bb039 /pcap-linux.c
parent30b93db53bd0d07fa9151af01eadf41c4fbc4ae2 (diff)
Use pcap_close() if pcap_create_handle() fails.
Use it to free up all memory attached to the pcap_t, as well as the pcap_t itself; that closes some memory leaks. Fixes GitHub issue #432.
Diffstat (limited to 'pcap-linux.c')
-rw-r--r--pcap-linux.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/pcap-linux.c b/pcap-linux.c
index a226da12..bb4619bb 100644
--- a/pcap-linux.c
+++ b/pcap-linux.c
@@ -459,7 +459,7 @@ pcap_create_interface(const char *device, char *ebuf)
* See what time stamp types we support.
*/
if (iface_ethtool_get_ts_info(handle, ebuf) == -1) {
- free(handle);
+ pcap_close(handle);
return NULL;
}
#endif
@@ -478,9 +478,7 @@ pcap_create_interface(const char *device, char *ebuf)
if (handle->tstamp_precision_list == NULL) {
snprintf(ebuf, PCAP_ERRBUF_SIZE, "malloc: %s",
pcap_strerror(errno));
- if (handle->tstamp_type_list != NULL)
- free(handle->tstamp_type_list);
- free(handle);
+ pcap_close(handle);
return NULL;
}
handle->tstamp_precision_list[0] = PCAP_TSTAMP_PRECISION_MICRO;