Fixed a leak in pcap_open_live (win32): the pcap_t handle was not freed
if PacketOpenAdapter fails. [The previous fix was in the wrong place].
This commit is contained in:
parent
5636631e58
commit
b1a06c1017
|
@ -32,7 +32,7 @@
|
||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
static const char rcsid[] _U_ =
|
static const char rcsid[] _U_ =
|
||||||
"@(#) $Header: /tcpdump/master/libpcap/pcap-win32.c,v 1.27 2005-06-10 03:49:19 risso Exp $ (LBL)";
|
"@(#) $Header: /tcpdump/master/libpcap/pcap-win32.c,v 1.28 2005-06-10 03:52:19 risso Exp $ (LBL)";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <pcap-int.h>
|
#include <pcap-int.h>
|
||||||
|
@ -411,6 +411,7 @@ pcap_open_live(const char *device, int snaplen, int promisc, int to_ms,
|
||||||
|
|
||||||
if (p->adapter == NULL)
|
if (p->adapter == NULL)
|
||||||
{
|
{
|
||||||
|
free(p);
|
||||||
/* Adapter detected but we are not able to open it. Return failure. */
|
/* Adapter detected but we are not able to open it. Return failure. */
|
||||||
snprintf(ebuf, PCAP_ERRBUF_SIZE, "Error opening adapter: %s", pcap_win32strerror());
|
snprintf(ebuf, PCAP_ERRBUF_SIZE, "Error opening adapter: %s", pcap_win32strerror());
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -419,7 +420,6 @@ pcap_open_live(const char *device, int snaplen, int promisc, int to_ms,
|
||||||
/*get network type*/
|
/*get network type*/
|
||||||
if(PacketGetNetType (p->adapter,&type) == FALSE)
|
if(PacketGetNetType (p->adapter,&type) == FALSE)
|
||||||
{
|
{
|
||||||
free(p);
|
|
||||||
snprintf(ebuf, PCAP_ERRBUF_SIZE, "Cannot determine the network type: %s", pcap_win32strerror());
|
snprintf(ebuf, PCAP_ERRBUF_SIZE, "Cannot determine the network type: %s", pcap_win32strerror());
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
|
|
Reference in New Issue