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.
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;
* See what time stamp types we support.
*/
if (iface_ethtool_get_ts_info(handle, ebuf) == -1) {
- free(handle);
+ pcap_close(handle);
return NULL;
}
#endif
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;
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;