Commit 1c6ea02f authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

userenv: GetProfilesDirectoryW accepts a NULL buffer.

parent 837fc836
......@@ -264,6 +264,23 @@ static void test_get_profiles_dir(void)
HeapFree(GetProcessHeap(), 0, buf);
HeapFree(GetProcessHeap(), 0, profiles_dir);
SetLastError(0xdeadbeef);
r = GetProfilesDirectoryW(NULL, NULL);
expect(FALSE, r);
expect_gle(ERROR_INVALID_PARAMETER);
cch = 0;
SetLastError(0xdeadbeef);
r = GetProfilesDirectoryW(NULL, &cch);
expect(FALSE, r);
expect_gle(ERROR_INSUFFICIENT_BUFFER);
ok(cch, "expected cch > 0\n");
SetLastError(0xdeadbeef);
r = GetProfilesDirectoryW(NULL, &cch);
expect(FALSE, r);
expect_gle(ERROR_INSUFFICIENT_BUFFER);
}
START_TEST(userenv)
......
......@@ -201,7 +201,7 @@ BOOL WINAPI GetProfilesDirectoryW( LPWSTR lpProfilesDir, LPDWORD lpcchSize )
TRACE("%p %p\n", lpProfilesDir, lpcchSize );
if (!lpProfilesDir || !lpcchSize)
if (!lpcchSize)
{
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
......@@ -234,7 +234,7 @@ BOOL WINAPI GetProfilesDirectoryW( LPWSTR lpProfilesDir, LPDWORD lpcchSize )
}
expanded_len = ExpandEnvironmentStringsW(unexpanded_profiles_dir, NULL, 0);
/* The returned length doesn't include the NULL terminator. */
if (*lpcchSize < expanded_len - 1)
if (*lpcchSize < expanded_len - 1 || !lpProfilesDir)
{
*lpcchSize = expanded_len - 1;
SetLastError(ERROR_INSUFFICIENT_BUFFER);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment