From 75ee14b8629082804de22d63734cbe36c95909cf Mon Sep 17 00:00:00 2001 From: patacongo Date: Tue, 29 Nov 2011 18:21:52 +0000 Subject: [PATCH] Fix handling of NULL pointer in sig_timedwait() git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4129 42af7a65-404d-4744-a932-0658087f49c3 --- ChangeLog | 4 +++- sched/sig_timedwait.c | 14 ++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) 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();