|
From: Mark W. <ma...@so...> - 2020-06-08 11:27:14
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=79818bf9a59c44576f99cfe32991eeed896bd51d commit 79818bf9a59c44576f99cfe32991eeed896bd51d Author: Mark Wielaard <ma...@kl...> Date: Mon Jun 8 13:24:47 2020 +0200 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: --- helgrind/hg_main.c | 5 +++++ 1 file changed, 5 insertions(+) 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 |