kernel: fix clearing of memory in LocalReAlloc16(...,
LMEM_ZEROMEMORY)
Mikołaj Zalewski
mikolaj at zalewski.pl
Sat Jun 2 14:41:52 CDT 2007
In the previous patch I've badly understood the meaning of
pArena->next and haven't noticed that oldsize doesn't include the
ARENA_HEADER_SIZE. In this patch the computation should be correct. It
also clear the bytes added by the alignment.
-------------- next part --------------
From 9cd84ff5cd93ab37c326c8f65b02904c74d1cd73 Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Miko=C5=82aj_Zalewski?= <mikolaj at zalewski.pl>
Date: Sat, 2 Jun 2007 21:31:28 +0200
Subject: [PATCH] kernel32: fix clearing of memory in LocalReAlloc16(..., LMEM_ZEROMEMORY)
---
dlls/kernel32/local16.c | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/dlls/kernel32/local16.c b/dlls/kernel32/local16.c
index 76b2a6d..87f11ed 100644
--- a/dlls/kernel32/local16.c
+++ b/dlls/kernel32/local16.c
@@ -1331,7 +1331,12 @@ 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);
+ {
+ char *oldend = (char *)pArena + ARENA_HEADER_SIZE + oldsize;
+ char *newend = ptr + pArena->next;
+ TRACE("Clearing memory from %p to %p (DS -> %p)\n", oldend, newend, ptr);
+ memset(oldend, 0, newend - oldend);
+ }
TRACE("returning %04x\n", handle );
return handle;
--
1.4.4.2
More information about the wine-patches
mailing list