Skip to content

Commit

Permalink
Merge pull request #124 from yury/fix-ios_dup2
Browse files Browse the repository at this point in the history
Check FILE* is not NULL before calling fileno function
  • Loading branch information
holzschu authored Oct 5, 2021
2 parents cf57413 + eb1b3a0 commit 23376c9
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions ios_system.m
Original file line number Diff line number Diff line change
Expand Up @@ -1696,9 +1696,9 @@ int ios_dup2(int fd1, int fd2)
case 2: child_stderr = stream1; return fd2;
}
}
if ((fd2 == 0) || (fd2 == fileno(thread_stdin))) { child_stdin = fdopen(fd1, "rb"); }
else if ((fd2 == 1) || (fd2 == fileno(thread_stdout))) { child_stdout = fdopen(fd1, "wb"); }
else if ((fd2 == 2) || (fd2 == fileno(thread_stderr))) {
if ((fd2 == 0) || (thread_stdin != NULL && fd2 == fileno(thread_stdin))) { child_stdin = fdopen(fd1, "rb"); }
else if ((fd2 == 1) || (thread_stdout != NULL && fd2 == fileno(thread_stdout))) { child_stdout = fdopen(fd1, "wb"); }
else if ((fd2 == 2) || (thread_stderr != NULL && fd2 == fileno(thread_stderr))) {
if ((child_stdout != NULL) && (fileno(child_stdout) == fd1)) child_stderr = child_stdout;
else child_stderr = fdopen(fd1, "wb"); }
else if (fd1 != fd2) {
Expand Down

0 comments on commit 23376c9

Please sign in to comment.