summaryrefslogtreecommitdiffstats
path: root/lib/libc/gen/popen.c
diff options
context:
space:
mode:
authorbde <bde@FreeBSD.org>1997-03-11 18:51:43 +0000
committerbde <bde@FreeBSD.org>1997-03-11 18:51:43 +0000
commit89013b759d296f0f99e532978864d5646f737ae2 (patch)
tree70020226e462c4c5c17c0fd92f1fa918218c1c5f /lib/libc/gen/popen.c
parentc555acba17ea242af9d4a85d4e2f7dbcee6515e6 (diff)
downloadFreeBSD-src-89013b759d296f0f99e532978864d5646f737ae2.zip
FreeBSD-src-89013b759d296f0f99e532978864d5646f737ae2.tar.gz
Fixed cleaning up after malloc failure, which was broken by Lite2.
We don't use socketpair(), so don't #include <sys/socket.h>. Restored some gcc-quieting parentheses that were lost in the Lite2 merge.
Diffstat (limited to 'lib/libc/gen/popen.c')
-rw-r--r--lib/libc/gen/popen.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/libc/gen/popen.c b/lib/libc/gen/popen.c
index ae809f5..f76f9e5 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 <sys/param.h>
#include <sys/wait.h>
-#include <sys/socket.h>
#include <signal.h>
#include <errno.h>
@@ -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. */
OpenPOWER on IntegriCloud