LibCore: Fix bug in CreateFileMapping call

size >> 31 >> 1 is used instead of size >> 32 to support 32-bit Windows
(size_t is 32 bit there, and you cannot shift 32-bit value by 32 bits
on x86)
This is equivalent to sizeof(size) == 4 ? 0 : size >> 32
This commit is contained in:
stasoid 2024-11-10 15:16:59 +05:00 committed by Andrew Kaster
commit dabf3da7e5
Notes: github-actions[bot] 2024-11-20 05:07:57 +00:00

View file

@ -28,7 +28,7 @@ AnonymousBufferImpl::~AnonymousBufferImpl()
ErrorOr<NonnullRefPtr<AnonymousBufferImpl>> AnonymousBufferImpl::create(size_t size)
{
HANDLE map_handle = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, HIWORD(size), LOWORD(size), NULL);
HANDLE map_handle = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, size >> 31 >> 1, size & 0xFFFFFFFF, NULL);
if (!map_handle)
return Error::from_windows_error(GetLastError());