From 0069651056940c13ec8956f05805734a113d17c6 Mon Sep 17 00:00:00 2001 From: Francois Gouget Date: Fri, 11 Jan 2008 09:52:31 +0100 Subject: [PATCH] kernel32/tests: Despite the MSDN claims, GetComputerName() does not return the required buffer size... except on Vista. So update the tests accordingly. --- dlls/kernel32/tests/environ.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/dlls/kernel32/tests/environ.c b/dlls/kernel32/tests/environ.c index a0e425c8eab..06943de0d9e 100644 --- a/dlls/kernel32/tests/environ.c +++ b/dlls/kernel32/tests/environ.c @@ -298,12 +298,17 @@ static void test_GetComputerName(void) error = GetLastError(); todo_wine ok(!ret && error == ERROR_BUFFER_OVERFLOW, "GetComputerNameA should have failed with ERROR_BUFFER_OVERFLOW instead of %d\n", error); - size++; /* nul terminating character */ - name = HeapAlloc(GetProcessHeap(), 0, size * sizeof(name[0])); - ok(name != NULL, "HeapAlloc failed with error %d\n", GetLastError()); - ret = GetComputerNameA(name, &size); - ok(ret, "GetComputerNameA failed with error %d\n", GetLastError()); - HeapFree(GetProcessHeap(), 0, name); + + /* Only Vista returns the computer name length as documented in the MSDN */ + if (size != 0) + { + size++; /* nul terminating character */ + name = HeapAlloc(GetProcessHeap(), 0, size * sizeof(name[0])); + ok(name != NULL, "HeapAlloc failed with error %d\n", GetLastError()); + ret = GetComputerNameA(name, &size); + ok(ret, "GetComputerNameA failed with error %d\n", GetLastError()); + HeapFree(GetProcessHeap(), 0, name); + } size = MAX_COMPUTERNAME_LENGTH + 1; name = HeapAlloc(GetProcessHeap(), 0, size * sizeof(name[0]));