Hans Leidekker : iphlpapi: Use a separate index to count addresses in GetAdaptersAddresses.

Alexandre Julliard julliard at winehq.org
Tue Jul 7 08:08:17 CDT 2009


Module: wine
Branch: master
Commit: cd1ed081def59bc912dab9a378d7eacd90396fea
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=cd1ed081def59bc912dab9a378d7eacd90396fea

Author: Hans Leidekker <hans at codeweavers.com>
Date:   Tue Jul  7 10:12:56 2009 +0200

iphlpapi: Use a separate index to count addresses in GetAdaptersAddresses.

Fixes address enumeration when an interfaces is not configured
with an IP address or when an interface is configured with more
than one address.

---

 dlls/iphlpapi/iphlpapi_main.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

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-cvs mailing list