Skip to content

Commit 94e73f6

Browse files
committed
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 <Florian.LaRoche@gmail.com>
1 parent 5a08982 commit 94e73f6

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

portable/ThirdParty/GCC/Posix/utils/wait_for_event.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,12 @@ struct event * event_create( void )
4343
{
4444
struct event * ev = malloc( sizeof( struct event ) );
4545

46-
ev->event_triggered = false;
47-
pthread_mutex_init( &ev->mutex, NULL );
48-
pthread_cond_init( &ev->cond, NULL );
46+
if( ev )
47+
{
48+
ev->event_triggered = false;
49+
pthread_mutex_init( &ev->mutex, NULL );
50+
pthread_cond_init( &ev->cond, NULL );
51+
}
4952
return ev;
5053
}
5154

0 commit comments

Comments
 (0)