Skip to content

Commit ab12b57

Browse files
larocheaggarg
authored andcommitted
event_create(): check malloc() return value to be non-NULL (FreeRTOS#1084)
* 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> * Code review suggestion Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com> --------- Signed-off-by: Florian La Roche <Florian.LaRoche@gmail.com> Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com> Co-authored-by: Gaurav-Aggarwal-AWS <33462878+aggarg@users.noreply.github.com> Co-authored-by: Gaurav Aggarwal <aggarg@amazon.com>
1 parent 51b474a commit ab12b57

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,13 @@ 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 != NULL )
47+
{
48+
ev->event_triggered = false;
49+
pthread_mutex_init( &ev->mutex, NULL );
50+
pthread_cond_init( &ev->cond, NULL );
51+
}
52+
4953
return ev;
5054
}
5155

0 commit comments

Comments
 (0)