From 035e5608d5ecb705f0a9e9992ef0f7bd704470b4 Mon Sep 17 00:00:00 2001 From: Bruce Evans Date: Tue, 11 Mar 1997 18:51:43 +0000 Subject: [PATCH] Fixed cleaning up after malloc failure, which was broken by Lite2. We don't use socketpair(), so don't #include . Restored some gcc-quieting parentheses that were lost in the Lite2 merge. --- lib/libc/gen/popen.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/libc/gen/popen.c b/lib/libc/gen/popen.c index ae809f5230e2..f76f9e56004c 100644 --- a/lib/libc/gen/popen.c +++ b/lib/libc/gen/popen.c @@ -40,7 +40,6 @@ static char sccsid[] = "@(#)popen.c 8.3 (Berkeley) 5/3/95"; #include #include -#include #include #include @@ -73,14 +72,17 @@ popen(command, type) type = "r+"; } else { twoway = 0; - if (*type != 'r' && *type != 'w' || type[1]) + if ((*type != 'r' && *type != 'w') || type[1]) return (NULL); } if (pipe(pdes) < 0) return (NULL); - if ((cur = malloc(sizeof(struct pid))) == NULL) + if ((cur = malloc(sizeof(struct pid))) == NULL) { + (void)close(pdes[0]); + (void)close(pdes[1]); return (NULL); + } switch (pid = vfork()) { case -1: /* Error. */