From 24e4f21763343acbc1867b4c983b782d4781283a Mon Sep 17 00:00:00 2001 From: delphij Date: Tue, 24 Jan 2017 07:48:36 +0000 Subject: [PATCH] Don't reference NULL pointer. MFC after: 2 weeks --- usr.bin/mail/popen.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/usr.bin/mail/popen.c b/usr.bin/mail/popen.c index 9cd4378245d4..7326f51bb64e 100644 --- a/usr.bin/mail/popen.c +++ b/usr.bin/mail/popen.c @@ -303,7 +303,7 @@ findchild(pid_t pid, int dont_alloc) cpp = &(*cpp)->link) ; if (*cpp == NULL) { - if (dont_alloc) + if (dont_alloc) return(NULL); if (child_freelist) { *cpp = child_freelist; @@ -344,6 +344,8 @@ sigchild(int signo __unused) save_errno = errno; while ((pid = waitpid(-1, &status, WNOHANG)) > 0) { cp = findchild(pid, 1); + if (cp == NULL) + continue; if (cp->free) delchild(cp); else {