]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
When looking for a heap segment to extend look for the heap limit
authorTom Hughes <tom@compton.nu>
Thu, 6 Oct 2005 14:49:21 +0000 (14:49 +0000)
committerTom Hughes <tom@compton.nu>
Thu, 6 Oct 2005 14:49:21 +0000 (14:49 +0000)
address rather than the base address as the heap may have been split
into more than one segment by using mprotect on it...

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@4882

coregrind/m_syswrap/syswrap-generic.c

index f4a9cb7e74bd12983e28daa3b199dc02c4140a91..39ce5eab1a8e6d914ec8d3834549465f816a6686 100644 (file)
@@ -952,7 +952,10 @@ static Addr do_brk ( Addr newbrk )
    }
 
    /* otherwise we're expanding the brk segment. */
-   aseg = VG_(am_find_nsegment)( VG_(brk_base) );
+   if (VG_(brk_limit) > VG_(brk_base))
+      aseg = VG_(am_find_nsegment)( VG_(brk_limit)-1 );
+   else
+      aseg = VG_(am_find_nsegment)( VG_(brk_limit) );
    rseg = VG_(am_next_nsegment)( aseg, True/*forwards*/ );
 
    /* These should be assured by setup_client_dataseg in m_main. */