aboutsummaryrefslogtreecommitdiff
path: root/pcap-snf.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-snf.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-snf.c')
-rw-r--r--pcap-snf.c4
1 files changed, 1 insertions, 3 deletions
diff --git a/pcap-snf.c b/pcap-snf.c
index 03dc08de..bfa0990e 100644
--- a/pcap-snf.c
+++ b/pcap-snf.c
@@ -483,9 +483,7 @@ snf_create(const char *device, char *ebuf, int *is_ours)
if (p->tstamp_precision_list == NULL) {
snprintf(ebuf, PCAP_ERRBUF_SIZE, "malloc: %s",
pcap_strerror(errno));
- if (p->tstamp_type_list != NULL)
- free(p->tstamp_type_list);
- free(p);
+ pcap_close(p);
return NULL;
}
p->tstamp_precision_list[0] = PCAP_TSTAMP_PRECISION_MICRO;