kernelbase: Fix VirtualAlloc2() when called with NULL process handle.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Nikolay Sivov 2022-05-20 09:36:53 +03:00 committed by Alexandre Julliard
parent 30f1777e87
commit 6fe7535c97
2 changed files with 1 additions and 2 deletions

View File

@ -352,6 +352,7 @@ LPVOID WINAPI DECLSPEC_HOTPATCH VirtualAlloc2( HANDLE process, void *addr, SIZE_
{
LPVOID ret = addr;
if (!process) process = GetCurrentProcess();
if (!set_ntstatus( NtAllocateVirtualMemoryEx( process, &ret, &size, type, protect, parameters, count )))
return NULL;
return ret;

View File

@ -142,10 +142,8 @@ static void test_VirtualAlloc2(void)
size = 0x80000;
addr = pVirtualAlloc2(NULL, NULL, size, MEM_COMMIT, PAGE_EXECUTE_READWRITE, NULL, 0);
todo_wine
ok(!!addr, "Failed to allocate, error %lu.\n", GetLastError());
ret = VirtualFree(addr, 0, MEM_RELEASE);
todo_wine
ok(ret, "Unexpected return value %d, error %lu.\n", ret, GetLastError());
/* Placeholder splitting functionality */