Alexandre Julliard : krnl386.exe: Page-align the GlobalAlloc() size when the selector limit is in pages.
Alexandre Julliard
julliard at winehq.org
Tue Apr 12 13:38:04 CDT 2022
Module: wine
Branch: oldstable
Commit: 2e51da6f1645394ccb7764a7f6b4b83439e3061e
URL: https://source.winehq.org/git/wine.git/?a=commit;h=2e51da6f1645394ccb7764a7f6b4b83439e3061e
Author: Alexandre Julliard <julliard at winehq.org>
Date: Sun Dec 12 17:57:55 2021 +0100
krnl386.exe: Page-align the GlobalAlloc() size when the selector limit is in pages.
GlobalSize() uses the selector limit and that needs to match the
allocated size.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52082
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
(cherry picked from commit 1c5e4d066f6cfd65cc5ad729ce6e8aff53e20939)
Signed-off-by: Michael Stefaniuc <mstefani at winehq.org>
---
dlls/krnl386.exe16/global.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/dlls/krnl386.exe16/global.c b/dlls/krnl386.exe16/global.c
index 0a8da28e99b..2eb02b8cef3 100644
--- a/dlls/krnl386.exe16/global.c
+++ b/dlls/krnl386.exe16/global.c
@@ -196,6 +196,7 @@ HGLOBAL16 GLOBAL_Alloc( UINT16 flags, DWORD size, HGLOBAL16 hOwner, unsigned cha
{
void *ptr;
HGLOBAL16 handle;
+ DWORD align = 0x1f;
TRACE("%d flags=%04x\n", size, flags );
@@ -205,8 +206,9 @@ HGLOBAL16 GLOBAL_Alloc( UINT16 flags, DWORD size, HGLOBAL16 hOwner, unsigned cha
/* Fixup the size */
- if (size >= GLOBAL_MAX_ALLOC_SIZE - 0x1f) return 0;
- size = (size + 0x1f) & ~0x1f;
+ if (size > 0x100000) align = 0xfff; /* selector limit will be in pages */
+ if (size >= GLOBAL_MAX_ALLOC_SIZE - align) return 0;
+ size = (size + align) & ~align;
/* Allocate the linear memory */
ptr = HeapAlloc( get_win16_heap(), 0, size );
More information about the wine-cvs
mailing list