Skip to content

Commit

Permalink
Fixed the issue of incorrect return value of PalVirtualAlloc (#112579)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
CeSun authored Feb 16, 2025
1 parent e334a1a commit 8a79637
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/coreclr/nativeaot/Runtime/unix/PalRedhawkUnix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -834,8 +834,10 @@ REDHAWK_PALEXPORT _Ret_maybenull_ _Post_writable_byte_size_(size) void* REDHAWK_
flags |= MAP_JIT;
}
#endif

return mmap(NULL, size, unixProtect, flags, -1, 0);
void* pMappedMemory = mmap(NULL, size, unixProtect, flags, -1, 0);
if (pMappedMemory == MAP_FAILED)
return NULL;
return pMappedMemory;
}

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

0 comments on commit 8a79637

Please sign in to comment.