diff options
-rw-r--r-- | pcap-dag.c | 4 | ||||
-rw-r--r-- | pcap-linux.c | 6 | ||||
-rw-r--r-- | pcap-snf.c | 4 |
3 files changed, 4 insertions, 10 deletions
@@ -950,9 +950,7 @@ pcap_t *dag_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; 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; @@ -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; |