From 0fc9a9e426499693c6c91552e20fed40c406e864 Mon Sep 17 00:00:00 2001 From: Paul Gofman Date: Thu, 11 May 2023 21:57:52 -0600 Subject: [PATCH] ntdll: Fix tail padding in mark_block_tail(). --- dlls/kernel32/tests/heap.c | 1 - dlls/ntdll/heap.c | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/dlls/kernel32/tests/heap.c b/dlls/kernel32/tests/heap.c index d2742b55495..8c101e1c47d 100644 --- a/dlls/kernel32/tests/heap.c +++ b/dlls/kernel32/tests/heap.c @@ -3127,7 +3127,6 @@ static void test_block_layout( HANDLE heap, DWORD global_flags, DWORD heap_flags ok( !memcmp( ptr1 + alloc_size, tail_buf, tail_size ), "missing block tail\n" ); ok( !memcmp( ptr2 + alloc_size, tail_buf, tail_size ), "missing block tail\n" ); - todo_wine_if( global_flags & FLG_HEAP_ENABLE_FREE_CHECK ) ok( !memcmp( ptr0 + alloc_size + tail_size, padd_buf, 2 * sizeof(void *) ), "unexpected padding\n" ); tmp_ptr = (void *)0xdeadbeef; diff --git a/dlls/ntdll/heap.c b/dlls/ntdll/heap.c index ef1a9c3f3b1..54aa1a8960d 100644 --- a/dlls/ntdll/heap.c +++ b/dlls/ntdll/heap.c @@ -500,8 +500,8 @@ static inline void mark_block_tail( struct block *block, DWORD flags ) if (flags & HEAP_ADD_USER_INFO) { if (flags & HEAP_TAIL_CHECKING_ENABLED || RUNNING_ON_VALGRIND) tail += BLOCK_ALIGN; - valgrind_make_writable( tail + sizeof(void *), sizeof(void *) ); - memset( tail + sizeof(void *), 0, sizeof(void *) ); + valgrind_make_writable( tail, BLOCK_ALIGN ); + memset( tail, 0, BLOCK_ALIGN ); } }