Added a check based on advise from Bisqwit.

This commit is contained in:
n-a-c-h
2006-03-11 23:08:20 +00:00
parent d61ba6ccc1
commit 3061122d8f
2 changed files with 2 additions and 2 deletions

View File

@@ -243,7 +243,7 @@ FILE *safe_popen(char *command, const char *mode)
//filedes[1] is for writing. //filedes[1] is for writing.
int filedes[2]; int filedes[2];
if ((*mode == 'r' || *mode == 'w') && !pipe(filedes)) if (mode && (*mode == 'r' || *mode == 'w') && !pipe(filedes))
{ {
pid_t childpid = parent_pause_fork(); pid_t childpid = parent_pause_fork();
if (IS_PARENT(childpid)) if (IS_PARENT(childpid))

View File

@@ -36,7 +36,7 @@ FILE *safe_popen(char *command, const char *mode)
{ {
int filedes[2]; int filedes[2];
if ((*mode == 'r' || *mode == 'w') && if (mode && (*mode == 'r' || *mode == 'w') &&
!pipe(filedes, 512, (mode[1] == 'b' ? O_BINARY : O_TEXT) | O_NOINHERIT)) !pipe(filedes, 512, (mode[1] == 'b' ? O_BINARY : O_TEXT) | O_NOINHERIT))
{ {
int fd_original; int fd_original;