iphlpapi: Use a seperate index to count addresses in GetAdaptersAddresses.
Hans Leidekker
hans at codeweavers.com
Tue Jul 7 03:12:56 CDT 2009
Fixes address enumeration when an interfaces is not configured
with an IP address or when an interface is configured with more
than one address.
-Hans
diff --git a/dlls/iphlpapi/iphlpapi_main.c b/dlls/iphlpapi/iphlpapi_main.c
index 8490c67..16cf1b3 100644
--- a/dlls/iphlpapi/iphlpapi_main.c
+++ b/dlls/iphlpapi/iphlpapi_main.c
@@ -611,7 +611,7 @@ static DWORD typeFromMibType(DWORD mib_type)
static ULONG addressesFromIndex(DWORD index, DWORD **addrs, ULONG *num_addrs)
{
- ULONG ret, i;
+ ULONG ret, i, j;
MIB_IPADDRTABLE *at;
*num_addrs = 0;
@@ -625,9 +625,9 @@ static ULONG addressesFromIndex(DWORD index, DWORD **addrs, ULONG *num_addrs)
HeapFree(GetProcessHeap(), 0, at);
return ERROR_OUTOFMEMORY;
}
- for (i = 0; i < at->dwNumEntries; i++)
+ for (i = 0, j = 0; i < at->dwNumEntries; i++)
{
- if (at->table[i].dwIndex == index) (*addrs)[i] = at->table[i].dwAddr;
+ if (at->table[i].dwIndex == index) (*addrs)[j++] = at->table[i].dwAddr;
}
HeapFree(GetProcessHeap(), 0, at);
return ERROR_SUCCESS;
More information about the wine-patches
mailing list