Skip to content

Commit 8a79637

Browse files
authored
Fixed the issue of incorrect return value of PalVirtualAlloc (#112579)
* Fixed the issue that the PalVirtualAlloc function did not return a NULL value correctly when memory allocation failed on Unix-like platforms * Fix variable name spelling
1 parent e334a1a commit 8a79637

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/coreclr/nativeaot/Runtime/unix/PalRedhawkUnix.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -834,8 +834,10 @@ REDHAWK_PALEXPORT _Ret_maybenull_ _Post_writable_byte_size_(size) void* REDHAWK_
834834
flags |= MAP_JIT;
835835
}
836836
#endif
837-
838-
return mmap(NULL, size, unixProtect, flags, -1, 0);
837+
void* pMappedMemory = mmap(NULL, size, unixProtect, flags, -1, 0);
838+
if (pMappedMemory == MAP_FAILED)
839+
return NULL;
840+
return pMappedMemory;
839841
}
840842

841843
REDHAWK_PALEXPORT void REDHAWK_PALAPI PalVirtualFree(_In_ void* pAddress, size_t size)

0 commit comments

Comments
 (0)