From: Tom Hughes Date: Thu, 6 Oct 2005 12:04:26 +0000 (+0000) Subject: Stop memalign crashing if it fails to allocate the memory. Bug 112538. X-Git-Tag: svn/VALGRIND_3_1_0~352 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c0893e8f7dee7e04f9f8bfc35afed82a68a7a7bc;p=thirdparty%2Fvalgrind.git Stop memalign crashing if it fails to allocate the memory. Bug 112538. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@4879 --- diff --git a/coregrind/m_mallocfree.c b/coregrind/m_mallocfree.c index 0be3f1b355..47c4873339 100644 --- a/coregrind/m_mallocfree.c +++ b/coregrind/m_mallocfree.c @@ -1200,6 +1200,10 @@ void* VG_(arena_memalign) ( ArenaId aid, SizeT req_alignB, SizeT req_pszB ) base_p = VG_(arena_malloc) ( aid, base_pszB_req ); a->bytes_on_loan = saved_bytes_on_loan; + /* Give up if we couldn't allocate enough space */ + if (base_p == 0) + return 0; + /* Block ptr for the block we are going to split. */ base_b = get_payload_block ( a, base_p );