iphlpapi: Don't allocate gobs of memory if interface table is empty.
diff --git a/dlls/iphlpapi/ifenum.c b/dlls/iphlpapi/ifenum.c
index 9590032..1ae70df 100644
--- a/dlls/iphlpapi/ifenum.c
+++ b/dlls/iphlpapi/ifenum.c
@@ -205,11 +205,13 @@
if (indexes) {
struct if_nameindex *p;
+ DWORD size = sizeof(InterfaceIndexTable);
for (p = indexes, numInterfaces = 0; p && p->if_name; p++)
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++)
ret->indexes[ret->numIndexes++] = p->if_index;