diff options
author | risso <risso> | 2004-04-30 09:13:51 +0000 |
---|---|---|
committer | risso <risso> | 2004-04-30 09:13:51 +0000 |
commit | e00313a3dbcab68a6a03e460cfb3d138e36223e0 (patch) | |
tree | 1513aac06c22383f06004c3449267b97c3a855e4 /inet.c | |
parent | 3787448b64d38260656ab807ebc8c98cd23fdea4 (diff) |
Fixed a memory leak in pcap_lookupdev under Win32.
Diffstat (limited to 'inet.c')
-rw-r--r-- | inet.c | 20 |
1 files changed, 15 insertions, 5 deletions
@@ -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); } } |