diff --git a/ChangeLog b/ChangeLog index de0f8872fa..523d11ddd7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2224,4 +2224,6 @@ board. * include/sys/types.h: wchar_t is a builtin type in C++ and its declaration can cause errors with certain C++ compilers. - + * sched/sig_timedwait.c: Fix signal handling with the returned info + is NULL. Before this change, it would derefence a NULL pointer + in this case. diff --git a/sched/sig_timedwait.c b/sched/sig_timedwait.c index dbbf444dcc..2d9afaab11 100644 --- a/sched/sig_timedwait.c +++ b/sched/sig_timedwait.c @@ -277,12 +277,18 @@ int sigtimedwait(FAR const sigset_t *set, FAR struct siginfo *info, if (info) { memcpy(info, &rtcb->sigunbinfo, sizeof(struct siginfo)); + + /* The return value is the number of the signal that awakened us */ + + ret = info->si_signo; + } + else + { + /* We don't know which signal awakened us. This is probably a bug. */ + + ret = 0; } irqrestore(saved_state); - - /* The return value is the number of the signal that awakened us */ - - ret = info->si_signo; } sched_unlock();