From 051cef2212d0c529d051dde39579d06accac9ab7 Mon Sep 17 00:00:00 2001 From: CarlTSpeak Date: Fri, 8 Aug 2025 14:52:03 +0100 Subject: [PATCH] fix: handle VirtualAlloc invalid size and flags --- src/windows-emulator/syscalls/memory.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/windows-emulator/syscalls/memory.cpp b/src/windows-emulator/syscalls/memory.cpp index 42ca451b..25895695 100644 --- a/src/windows-emulator/syscalls/memory.cpp +++ b/src/windows-emulator/syscalls/memory.cpp @@ -181,6 +181,12 @@ namespace syscalls } auto allocation_bytes = bytes_to_allocate.read(); + + if (allocation_bytes == 0) + { + return STATUS_INVALID_PARAMETER; + } + allocation_bytes = page_align_up(allocation_bytes); bytes_to_allocate.write(allocation_bytes); @@ -244,6 +250,11 @@ namespace syscalls return STATUS_NOT_SUPPORTED; } + if (free_type == 0) + { + return STATUS_INVALID_PARAMETER; + } + const auto allocation_base = base_address.read(); const auto allocation_size = bytes_to_allocate.read();