Added a check based on advise from Bisqwit.
This commit is contained in:
@@ -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))
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
Reference in New Issue
Block a user