1
0
mirror of https://github.com/gryf/wmaker.git synced 2026-01-09 23:34:14 +01:00

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 <christophe.curis@free.fr>
This commit is contained in:
Christophe CURIS
2014-05-18 00:56:38 +02:00
committed by Carlos R. Mafra
parent 978cb1f154
commit 05f88d0aa7

View File

@@ -30,6 +30,10 @@
#include <assert.h> #include <assert.h>
#include <signal.h> #include <signal.h>
#ifdef HAVE_STDNORETURN
#include <stdnoreturn.h>
#endif
#ifdef USE_BOEHM_GC #ifdef USE_BOEHM_GC
#ifndef GC_DEBUG #ifndef GC_DEBUG
#define GC_DEBUG #define GC_DEBUG
@@ -54,7 +58,11 @@ static void defaultHandler(int bla)
static waborthandler *aborthandler = defaultHandler; static waborthandler *aborthandler = defaultHandler;
#define wAbort(a) (*aborthandler)(a) static inline noreturn void wAbort(int bla)
{
(*aborthandler)(bla);
exit(-1);
}
waborthandler *wsetabort(waborthandler * handler) waborthandler *wsetabort(waborthandler * handler)
{ {