sched/sched/sched_waitpid.c: Fix null pointer derefence on race without DEBUG_ASSERT.

This commit is contained in:
David Alessio
2019-11-05 08:59:01 -06:00
committed by Gregory Nutt
parent e2976c5b4e
commit 1c3d6ea24b
+6 -3
View File
@@ -547,10 +547,13 @@ pid_t waitpid(pid_t pid, int *stat_loc, int options)
child = group_exitchild(rtcb->group);
DEBUGASSERT(child != NULL);
/* Discard the child entry */
/* Discard the child entry, if we have one */
(void)group_removechild(rtcb->group, child->ch_pid);
group_freechild(child);
if (child != NULL)
{
(void)group_removechild(rtcb->group, child->ch_pid);
group_freechild(child);
}
}
#endif /* CONFIG_SCHED_CHILD_STATUS */