From 6bb413270ba254d2592b22cb4a1a7283e9989cbd Mon Sep 17 00:00:00 2001 From: Michael Lotz Date: Thu, 22 Oct 2009 12:05:50 +0000 Subject: [PATCH] The allocation size wasn't updated on an area based realloc that would still fit into the existing area. In that case further reallocs could then assume the wrong previous size and then not copy enough from the original buffer, leading to lost bytes at the end of the new buffer. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33724 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/system/kernel/heap.cpp | 1 + src/system/libroot/posix/malloc_debug/heap.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/src/system/kernel/heap.cpp b/src/system/kernel/heap.cpp index c2e611605e..e4e2dd5e41 100644 --- a/src/system/kernel/heap.cpp +++ b/src/system/kernel/heap.cpp @@ -2263,6 +2263,7 @@ realloc(void *address, size_t newSize) // there is enough room available for the newSize TRACE(("realloc(): new size %ld fits in old area %ld with %ld " "available\n", newSize, area, available)); + info->allocation_size = newSize; return address; } diff --git a/src/system/libroot/posix/malloc_debug/heap.cpp b/src/system/libroot/posix/malloc_debug/heap.cpp index ad8f88faac..c25a807156 100644 --- a/src/system/libroot/posix/malloc_debug/heap.cpp +++ b/src/system/libroot/posix/malloc_debug/heap.cpp @@ -1689,6 +1689,7 @@ realloc(void *address, size_t newSize) // there is enough room available for the newSize INFO(("realloc(): new size %ld fits in old area %ld with %ld " "available\n", newSize, area, available)); + info->allocation_size = newSize; return address; }