From b61b5a2470b052483a959a4f477d3cd657712caa Mon Sep 17 00:00:00 2001 From: Ilia Date: Fri, 24 Mar 2023 22:36:24 +0100 Subject: [PATCH] Fix reserving executable memory as per allocation type in ClrVirtualAllocWithinRange() (#83819) Fixes #83818 --- src/coreclr/utilcode/util.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/coreclr/utilcode/util.cpp b/src/coreclr/utilcode/util.cpp index 0901e06..ddf60c6 100644 --- a/src/coreclr/utilcode/util.cpp +++ b/src/coreclr/utilcode/util.cpp @@ -369,7 +369,7 @@ BYTE * ClrVirtualAllocWithinRange(const BYTE *pMinAddr, { NOTHROW; PRECONDITION(dwSize != 0); - PRECONDITION(flAllocationType == MEM_RESERVE); + PRECONDITION(flAllocationType == MEM_RESERVE); // ORed with MEM_RESERVE_EXECUTABLE on Unix } CONTRACTL_END; @@ -449,7 +449,7 @@ BYTE * ClrVirtualAllocWithinRange(const BYTE *pMinAddr, (mbInfo.RegionSize >= (SIZE_T) dwSize || mbInfo.RegionSize == 0)) { // Try reserving the memory using VirtualAlloc now - pResult = (BYTE*)ClrVirtualAlloc(tryAddr, dwSize, MEM_RESERVE, flProtect); + pResult = (BYTE*)ClrVirtualAlloc(tryAddr, dwSize, flAllocationType, flProtect); // Normally this will be successful // -- 2.7.4