Juan Lang : iphlpapi: Don' t allocate gobs of memory if there are no non-loopback interfaces.
Alexandre Julliard
julliard at winehq.org
Fri Nov 16 08:31:18 CST 2007
Module: wine
Branch: master
Commit: 0502de41ae463181620ebcb956fe7d15cec5d8c3
URL: http://source.winehq.org/git/wine.git/?a=commit;h=0502de41ae463181620ebcb956fe7d15cec5d8c3
Author: Juan Lang <juan.lang at gmail.com>
Date: Thu Nov 15 11:06:50 2007 -0800
iphlpapi: Don't allocate gobs of memory if there are no non-loopback interfaces.
---
dlls/iphlpapi/ifenum.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/dlls/iphlpapi/ifenum.c b/dlls/iphlpapi/ifenum.c
index 0a74ef6..36c42fe 100644
--- a/dlls/iphlpapi/ifenum.c
+++ b/dlls/iphlpapi/ifenum.c
@@ -234,12 +234,14 @@ InterfaceIndexTable *getNonLoopbackInterfaceIndexTable(void)
if (indexes) {
struct if_nameindex *p;
+ DWORD size = sizeof(InterfaceIndexTable);
for (p = indexes, numInterfaces = 0; p && p->if_name; p++)
if (!isLoopbackInterface(fd, p->if_name))
numInterfaces++;
- ret = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
- sizeof(InterfaceIndexTable) + (numInterfaces - 1) * sizeof(DWORD));
+ if (numInterfaces > 1)
+ size += (numInterfaces - 1) * sizeof(DWORD);
+ ret = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size);
if (ret) {
for (p = indexes; p && p->if_name; p++)
if (!isLoopbackInterface(fd, p->if_name))
More information about the wine-cvs
mailing list