kernel: clear the extra memory in LocalReAlloc16(h, bigger_size,
LMEM_ZEROINIT) (fixes bug #7031)
Mikołaj Zalewski
mikolaj at zalewski.pl
Wed May 30 05:37:54 CDT 2007
Hogia Hemekonomi resizes an array with a LocalReAlloc16 and crashes
because a field in the new cell isn't NULL nor a valid segment handle.
That's because the extra memory isn't cleared when we enlarge a block
in-place. If I understand the code correctly this should fix it. Other
code paths are OK as they use LOCAL_GetBlock that honors the LMEM_ZEROINIT.
-------------- next part --------------
From edaf7105223f471dc248635d5dc5953c7a6f51e4 Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Miko=C5=82aj_Zalewski?= <mikolaj at zalewski.pl>
Date: Wed, 30 May 2007 10:06:34 +0200
Subject: [PATCH] kernel: clear the extra memory in LocalReAlloc16(h, bigger_size, LMEM_ZEROINIT)
---
dlls/kernel32/local16.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/dlls/kernel32/local16.c b/dlls/kernel32/local16.c
index eb8df76..76b2a6d 100644
--- a/dlls/kernel32/local16.c
+++ b/dlls/kernel32/local16.c
@@ -1330,6 +1330,9 @@ HLOCAL16 WINAPI LocalReAlloc16( HLOCAL16 handle, WORD size, UINT16 flags )
{
TRACE("size increase, making new free block\n");
LOCAL_GrowArenaUpward(ds, arena, nextarena - arena);
+ if (flags & LMEM_ZEROINIT)
+ memset((char *)pArena + oldsize, 0, size - oldsize);
+
TRACE("returning %04x\n", handle );
return handle;
}
--
1.4.4.2
More information about the wine-patches
mailing list