From: Paul Gofman pgofman@codeweavers.com
Signed-off-by: Paul Gofman pgofman@codeweavers.com --- dlls/iphlpapi/iphlpapi_main.c | 7 +++++++ dlls/iphlpapi/tests/iphlpapi.c | 8 ++++---- 2 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/dlls/iphlpapi/iphlpapi_main.c b/dlls/iphlpapi/iphlpapi_main.c index 5a4acdb9c5a..33b12361d70 100644 --- a/dlls/iphlpapi/iphlpapi_main.c +++ b/dlls/iphlpapi/iphlpapi_main.c @@ -2326,6 +2326,13 @@ DWORD WINAPI GetIpNetTable( MIB_IPNETTABLE *table, ULONG *size, BOOL sort ) }
table->dwNumEntries = count; + + if (!count) + { + err = ERROR_NO_DATA; + goto err; + } + for (i = 0; i < count; i++) { MIB_IPNETROW *row = table->table + i; diff --git a/dlls/iphlpapi/tests/iphlpapi.c b/dlls/iphlpapi/tests/iphlpapi.c index c40ae3989c6..29256eb2774 100644 --- a/dlls/iphlpapi/tests/iphlpapi.c +++ b/dlls/iphlpapi/tests/iphlpapi.c @@ -388,11 +388,11 @@ static void testGetIpNetTable(void) else if (apiReturn == ERROR_INSUFFICIENT_BUFFER) { PMIB_IPNETTABLE buf = HeapAlloc(GetProcessHeap(), 0, dwSize);
+ memset(buf, 0xcc, dwSize); apiReturn = GetIpNetTable(buf, &dwSize, FALSE); - ok(apiReturn == NO_ERROR || - apiReturn == ERROR_NO_DATA, /* empty ARP table's okay */ - "GetIpNetTable(buf, &dwSize, FALSE) returned %ld, expected NO_ERROR\n", - apiReturn); + ok((apiReturn == NO_ERROR && buf->dwNumEntries) || (apiReturn == ERROR_NO_DATA && !buf->dwNumEntries), + "got apiReturn %lu, dwSize %lu, buf->dwNumEntries %lu.\n", + apiReturn, dwSize, buf->dwNumEntries);
if (apiReturn == NO_ERROR && winetest_debug > 1) {