Skip to content

Commit

Permalink
Check FILE* is not NULL before calling fileno function
Browse files Browse the repository at this point in the history
  • Loading branch information
yury committed Oct 5, 2021
1 parent c6973b3 commit a56b915
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 @@ -1694,9 +1694,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 a56b915

Please sign in to comment.