From 05f88d0aa7db556d3e4f89cb3f4cd96cd9a46730 Mon Sep 17 00:00:00 2001 From: Christophe CURIS Date: Sun, 18 May 2014 00:56:38 +0200 Subject: [PATCH] WUtil: make sure wmalloc/wrealloc won't fail because of abort handler As pointed by Coverity (#50074), despite the expected behaviour that 'wmalloc' should never return NULL, it may still happen if an abort handler set by user (with wsetabort) does not call exit() as expected. In such case we call exit ourself to be sure not to return NULL. Signed-off-by: Christophe CURIS --- WINGs/memory.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/WINGs/memory.c b/WINGs/memory.c index 7f4f0a85..81476e45 100644 --- a/WINGs/memory.c +++ b/WINGs/memory.c @@ -30,6 +30,10 @@ #include #include +#ifdef HAVE_STDNORETURN +#include +#endif + #ifdef USE_BOEHM_GC #ifndef GC_DEBUG #define GC_DEBUG @@ -54,7 +58,11 @@ static void defaultHandler(int bla) static waborthandler *aborthandler = defaultHandler; -#define wAbort(a) (*aborthandler)(a) +static inline noreturn void wAbort(int bla) +{ + (*aborthandler)(bla); + exit(-1); +} waborthandler *wsetabort(waborthandler * handler) {