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

Alexandre Julliard julliard at winehq.org
Fri May 20 15:26:47 CDT 2022


Module: wine
Branch: master
Commit: 6fe7535c977ea5b6639561b0bce42e324217695f
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=6fe7535c977ea5b6639561b0bce42e324217695f

Author: Nikolay Sivov <nsivov at codeweavers.com>
Date:   Fri May 20 09:36:53 2022 +0300

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

Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/kernelbase/memory.c        | 1 +
 dlls/kernelbase/tests/process.c | 2 --
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/dlls/kernelbase/memory.c b/dlls/kernelbase/memory.c
index 656569220fa..416d7b52a16 100644
--- a/dlls/kernelbase/memory.c
+++ b/dlls/kernelbase/memory.c
@@ -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;
diff --git a/dlls/kernelbase/tests/process.c b/dlls/kernelbase/tests/process.c
index 52c481a59e8..b83a25015b2 100644
--- a/dlls/kernelbase/tests/process.c
+++ b/dlls/kernelbase/tests/process.c
@@ -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 */




More information about the wine-cvs mailing list