From: Tom Hughes Date: Thu, 6 Oct 2005 14:49:21 +0000 (+0000) Subject: When looking for a heap segment to extend look for the heap limit X-Git-Tag: svn/VALGRIND_3_1_0~350 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=193e4670fcdd0189096c39c00a18cb0cbb2be289;p=thirdparty%2Fvalgrind.git When looking for a heap segment to extend look for the heap limit 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 --- diff --git a/coregrind/m_syswrap/syswrap-generic.c b/coregrind/m_syswrap/syswrap-generic.c index f4a9cb7e74..39ce5eab1a 100644 --- a/coregrind/m_syswrap/syswrap-generic.c +++ b/coregrind/m_syswrap/syswrap-generic.c @@ -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. */