From b024c395d7eaa61d7e784c380e924c59ddd043f6 Mon Sep 17 00:00:00 2001 From: Michael Lotz Date: Tue, 19 Feb 2008 00:42:54 +0000 Subject: [PATCH] Fix bad error in calculating the leak check info address when updating the size of a reallocated block. If you had kernel heap leak checking on, this could have caused the first four bytes of the next block to be overwritten with the size of the reallocation of the previous block. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24011 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/system/kernel/heap.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/system/kernel/heap.cpp b/src/system/kernel/heap.cpp index 41e2c3ecc0..831c310f5a 100644 --- a/src/system/kernel/heap.cpp +++ b/src/system/kernel/heap.cpp @@ -931,7 +931,8 @@ heap_realloc(heap_allocator *heap, void *address, void **newAddress, if (newSize > minSize && newSize <= maxSize) { #if KERNEL_HEAP_LEAK_CHECK // update the size info (the info is at the end so stays where it is) - heap_leak_check_info *info = (heap_leak_check_info *)((addr_t)address + maxSize); + heap_leak_check_info *info = (heap_leak_check_info *)((addr_t)address + + maxSize - sizeof(heap_leak_check_info)); info->size = newSize - sizeof(heap_leak_check_info); newSize -= sizeof(heap_leak_check_info); #endif