mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-14 10:09:48 +00:00
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.
This commit is contained in:
parent
1662ffff99
commit
035e5608d5
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=23734
@ -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. */
|
||||
|
Loading…
Reference in New Issue
Block a user