aboutsummaryrefslogtreecommitdiffstats
path: root/inet.c
diff options
context:
space:
mode:
authorrisso <risso>2004-04-30 09:13:51 +0000
committerrisso <risso>2004-04-30 09:13:51 +0000
commite00313a3dbcab68a6a03e460cfb3d138e36223e0 (patch)
tree1513aac06c22383f06004c3449267b97c3a855e4 /inet.c
parent3787448b64d38260656ab807ebc8c98cd23fdea4 (diff)
Fixed a memory leak in pcap_lookupdev under Win32.
Diffstat (limited to 'inet.c')
-rw-r--r--inet.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/inet.c b/inet.c
index 7a8bf3d..5775683 100644
--- a/inet.c
+++ b/inet.c
@@ -34,7 +34,7 @@
#ifndef lint
static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/libpcap/inet.c,v 1.59 2003-11-15 23:24:00 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/libpcap/inet.c,v 1.60 2004-04-30 09:13:51 risso Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -597,9 +597,10 @@ pcap_lookupdev(errbuf)
ULONG NameLength = 8192;
static char AdaptersName[8192];
- PacketGetAdapterNames(AdaptersName,&NameLength);
-
- return (AdaptersName);
+ if (PacketGetAdapterNames(AdaptersName,&NameLength) )
+ return (AdaptersName);
+ else
+ return NULL;
} else {
/*
* Windows NT (NT 4.0, W2K, WXP). Convert the names to UNICODE for backward compatibility
@@ -617,7 +618,15 @@ pcap_lookupdev(errbuf)
return NULL;
}
- PacketGetAdapterNames((PTSTR)TAdaptersName,&NameLength);
+ if ( !PacketGetAdapterNames((PTSTR)TAdaptersName,&NameLength) )
+ {
+ (void)snprintf(errbuf, PCAP_ERRBUF_SIZE,
+ "PacketGetAdapterNames: %s",
+ pcap_win32strerror());
+ free(TAdaptersName);
+ return NULL;
+ }
+
tAstr = (char*)TAdaptersName;
tUstr = (WCHAR*)AdaptersName;
@@ -646,6 +655,7 @@ pcap_lookupdev(errbuf)
tAstr += strlen(tAstr) + 1;
}
+ free(TAdaptersName);
return (char *)(AdaptersName);
}
}