From 94e73f6f0cef2c419540633bdf359b7035ac9ccf Mon Sep 17 00:00:00 2001 From: Florian La Roche Date: Thu, 6 Jun 2024 21:36:02 +0200 Subject: [PATCH] event_create(): check malloc() to be non-NULL Check malloc() to return non-NULL before writing data in the function event_create(). Signed-off-by: Florian La Roche --- portable/ThirdParty/GCC/Posix/utils/wait_for_event.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/portable/ThirdParty/GCC/Posix/utils/wait_for_event.c b/portable/ThirdParty/GCC/Posix/utils/wait_for_event.c index beca2b360..40a428df0 100644 --- a/portable/ThirdParty/GCC/Posix/utils/wait_for_event.c +++ b/portable/ThirdParty/GCC/Posix/utils/wait_for_event.c @@ -43,9 +43,12 @@ struct event * event_create( void ) { struct event * ev = malloc( sizeof( struct event ) ); - ev->event_triggered = false; - pthread_mutex_init( &ev->mutex, NULL ); - pthread_cond_init( &ev->cond, NULL ); + if( ev ) + { + ev->event_triggered = false; + pthread_mutex_init( &ev->mutex, NULL ); + pthread_cond_init( &ev->cond, NULL ); + } return ev; }