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.
This commit is contained in:
parent
10b38faf3a
commit
e7d91129d9
|
@ -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 );
|
||||
|
|
Loading…
Reference in New Issue