From dabf3da7e549714a2eeb3658f863c307ceabc5fe Mon Sep 17 00:00:00 2001 From: stasoid Date: Sun, 10 Nov 2024 15:16:59 +0500 Subject: [PATCH] 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 --- Libraries/LibCore/AnonymousBufferWindows.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Libraries/LibCore/AnonymousBufferWindows.cpp b/Libraries/LibCore/AnonymousBufferWindows.cpp index 91baddd0859..a0089a290ec 100644 --- a/Libraries/LibCore/AnonymousBufferWindows.cpp +++ b/Libraries/LibCore/AnonymousBufferWindows.cpp @@ -28,7 +28,7 @@ AnonymousBufferImpl::~AnonymousBufferImpl() ErrorOr> 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());