Skip to content

Commit eb1b3a0

Browse files
committed
Check FILE* is not NULL before calling fileno function
1 parent 6a9b249 commit eb1b3a0

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

ios_system.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1694,9 +1694,9 @@ int ios_dup2(int fd1, int fd2)
16941694
case 2: child_stderr = stream1; return fd2;
16951695
}
16961696
}
1697-
if ((fd2 == 0) || (fd2 == fileno(thread_stdin))) { child_stdin = fdopen(fd1, "rb"); }
1698-
else if ((fd2 == 1) || (fd2 == fileno(thread_stdout))) { child_stdout = fdopen(fd1, "wb"); }
1699-
else if ((fd2 == 2) || (fd2 == fileno(thread_stderr))) {
1697+
if ((fd2 == 0) || (thread_stdin != NULL && fd2 == fileno(thread_stdin))) { child_stdin = fdopen(fd1, "rb"); }
1698+
else if ((fd2 == 1) || (thread_stdout != NULL && fd2 == fileno(thread_stdout))) { child_stdout = fdopen(fd1, "wb"); }
1699+
else if ((fd2 == 2) || (thread_stderr != NULL && fd2 == fileno(thread_stderr))) {
17001700
if ((child_stdout != NULL) && (fileno(child_stdout) == fd1)) child_stderr = child_stdout;
17011701
else child_stderr = fdopen(fd1, "wb"); }
17021702
else if (fd1 != fd2) {

0 commit comments

Comments
 (0)