From: Julian Seward Date: Tue, 29 Jul 2008 09:44:52 +0000 (+0000) Subject: Add a followup comment to the changes in r8454, which made memcheck's X-Git-Tag: svn/VALGRIND_3_4_0~303 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e448622e08e9dc34f0f96145ff4bc2c7422a47e1;p=thirdparty%2Fvalgrind.git Add a followup comment to the changes in r8454, which made memcheck's client realloc function use an always-move strategy. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@8469 --- diff --git a/memcheck/mc_malloc_wrappers.c b/memcheck/mc_malloc_wrappers.c index cfc1e57ac5..07cb484adb 100644 --- a/memcheck/mc_malloc_wrappers.c +++ b/memcheck/mc_malloc_wrappers.c @@ -372,6 +372,14 @@ void* MC_(realloc) ( ThreadId tid, void* p_old, SizeT new_szB ) old_szB = mc->szB; + /* In all cases, even when the new size is smaller or unchanged, we + reallocate and copy the contents, and make the old block + inaccessible. This is so as to guarantee to catch all cases of + accesses via the old address after reallocation, regardless of + the change in size. (Of course the ability to detect accesses + to the old block also depends on the size of the freed blocks + queue). */ + if (new_szB <= old_szB) { /* new size is smaller or the same */ Addr a_new;