diff options
-rw-r--r-- | lib/libc_r/uthread/uthread_close.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/libc_r/uthread/uthread_close.c b/lib/libc_r/uthread/uthread_close.c index 22c9394..dedd3e9 100644 --- a/lib/libc_r/uthread/uthread_close.c +++ b/lib/libc_r/uthread/uthread_close.c @@ -49,9 +49,11 @@ _close(int fd) struct stat sb; struct fd_table_entry *entry; - if ((fd == _thread_kern_pipe[0]) || (fd == _thread_kern_pipe[1])) { + if ((fd == _thread_kern_pipe[0]) || (fd == _thread_kern_pipe[1]) || + (_thread_fd_table[fd] == NULL)) { /* - * Don't allow silly programs to close the kernel pipe. + * Don't allow silly programs to close the kernel pipe + * and non-active descriptors. */ errno = EBADF; ret = -1; |