Rob Shearman : ntdll: When using HEAP_ZERO_MEMORY in heap allocation functions, don' t clear the whole block.
Alexandre Julliard
julliard at winehq.org
Thu Feb 21 07:42:42 CST 2008
Module: wine
Branch: master
Commit: e7d91129d9ba966b12f4dc6ba8100886d85102f7
URL: http://source.winehq.org/git/wine.git/?a=commit;h=e7d91129d9ba966b12f4dc6ba8100886d85102f7
Author: Rob Shearman <rob at codeweavers.com>
Date: Wed Feb 20 12:57:30 2008 +0000
ntdll: When using HEAP_ZERO_MEMORY in heap allocation functions, don't clear the whole block.
Instead only clear the number of bytes requested and mark the remainder
as uninitialised.
---
dlls/ntdll/heap.c | 13 +++++++++----
1 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/dlls/ntdll/heap.c b/dlls/ntdll/heap.c
index ce95c5d..3cd59f7 100644
--- a/dlls/ntdll/heap.c
+++ b/dlls/ntdll/heap.c
@@ -1231,7 +1231,10 @@ PVOID WINAPI RtlAllocateHeap( HANDLE heap, ULONG flags, SIZE_T size )
notify_alloc( pInUse + 1, size, flags & HEAP_ZERO_MEMORY );
if (flags & HEAP_ZERO_MEMORY)
- clear_block( pInUse + 1, pInUse->size & ARENA_SIZE_MASK );
+ {
+ clear_block( pInUse + 1, size );
+ mark_block_uninitialized( (char *)(pInUse + 1) + size, pInUse->unused_bytes );
+ }
else
mark_block_uninitialized( pInUse + 1, pInUse->size & ARENA_SIZE_MASK );
@@ -1431,11 +1434,13 @@ PVOID WINAPI RtlReAllocateHeap( HANDLE heap, ULONG flags, PVOID ptr, SIZE_T size
/* Clear the extra bytes if needed */
- if ((pArena->size & ARENA_SIZE_MASK) > oldActualSize)
+ if (size > oldActualSize)
{
if (flags & HEAP_ZERO_MEMORY)
- clear_block( (char *)(pArena + 1) + oldActualSize,
- (pArena->size & ARENA_SIZE_MASK) - oldActualSize );
+ {
+ clear_block( (char *)(pArena + 1) + oldActualSize, size - oldActualSize );
+ mark_block_uninitialized( (char *)(pArena + 1) + size, pArena->unused_bytes );
+ }
else
mark_block_uninitialized( (char *)(pArena + 1) + oldActualSize,
(pArena->size & ARENA_SIZE_MASK) - oldActualSize );
More information about the wine-cvs
mailing list