From: Mark Wielaard Date: Mon, 8 Jun 2020 11:24:47 +0000 (+0200) Subject: helgrind: If hg_cli__realloc fails, return NULL. X-Git-Tag: VALGRIND_3_17_0~190 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=79818bf9a59c44576f99cfe32991eeed896bd51d;p=thirdparty%2Fvalgrind.git helgrind: If hg_cli__realloc fails, return NULL. helgrind would not handle a failing realloc correctly and assume cli_malloc would always succeed. If cli_malloc fails in hg_cli__realloc do like dh and massif and fail the realloc call by returning NULL. --- diff --git a/helgrind/hg_main.c b/helgrind/hg_main.c index 8b8dd05498..26b0c5a123 100644 --- a/helgrind/hg_main.c +++ b/helgrind/hg_main.c @@ -4331,6 +4331,11 @@ static void* hg_cli__realloc ( ThreadId tid, void* payloadV, SizeT new_size ) /* else */ { /* new size is bigger */ Addr p_new = (Addr)VG_(cli_malloc)(VG_(clo_alignment), new_size); + if (!p_new) { + // Nb: if realloc fails, NULL is returned but the old block is not + // touched. What an awful function. + return NULL; + } /* First half kept and copied, second half new */ // FIXME: shouldn't we use a copier which implements the