kernelbase: Fix GetEnvironmentVariableW return for empty variables.
Do the same thing as Vista and up. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=48471 Signed-off-by: Vladimir Panteleev <git@vladimir.panteleev.md> Signed-off-by: Gijs Vermeulen <gijsvrm@gmail.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
4c06599c1f
commit
c4ef987429
|
@ -168,6 +168,16 @@ static void test_GetSetEnvironmentVariableA(void)
|
|||
"%s should be set to \"\" (NT) or removed (Win9x) but ret_size=%d GetLastError=%d and buf=%s\n",
|
||||
name, ret_size, GetLastError(), buf);
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
ret_size = GetEnvironmentVariableA(name, NULL, 0);
|
||||
ok(ret_size == 1 ||
|
||||
broken(ret_size == 0), /* XP */
|
||||
"should return 1 for empty string but ret_size=%d GetLastError=%d\n",
|
||||
ret_size, GetLastError());
|
||||
ok(GetLastError() == 0xdeadbeef ||
|
||||
broken(GetLastError() == ERROR_MORE_DATA), /* XP */
|
||||
"should not fail with zero size but GetLastError=%d\n", GetLastError());
|
||||
|
||||
/* Test the limits */
|
||||
SetLastError(0xdeadbeef);
|
||||
ret_size = GetEnvironmentVariableA(NULL, NULL, 0);
|
||||
|
@ -277,6 +287,16 @@ static void test_GetSetEnvironmentVariableW(void)
|
|||
ret_size, GetLastError());
|
||||
ok(lstrcmpW(buf, empty_strW) == 0, "should copy an empty string\n");
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
ret_size = GetEnvironmentVariableW(name, NULL, 0);
|
||||
ok(ret_size == 1 ||
|
||||
broken(ret_size == 0), /* XP */
|
||||
"should return 1 for empty string but ret_size=%d GetLastError=%d\n",
|
||||
ret_size, GetLastError());
|
||||
ok(GetLastError() == 0xdeadbeef ||
|
||||
broken(GetLastError() == ERROR_MORE_DATA), /* XP */
|
||||
"should not fail with zero size but GetLastError=%d\n", GetLastError());
|
||||
|
||||
/* Test the limits */
|
||||
SetLastError(0xdeadbeef);
|
||||
ret_size = GetEnvironmentVariableW(NULL, NULL, 0);
|
||||
|
|
|
@ -1397,7 +1397,8 @@ DWORD WINAPI DECLSPEC_HOTPATCH GetEnvironmentVariableW( LPCWSTR name, LPWSTR val
|
|||
len = us_value.Length / sizeof(WCHAR);
|
||||
if (status == STATUS_BUFFER_TOO_SMALL) return len + 1;
|
||||
if (!set_ntstatus( status )) return 0;
|
||||
if (size) val[len] = 0;
|
||||
if (!size) return len + 1;
|
||||
val[len] = 0;
|
||||
return len;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue