From bc669a8c3395341be49f56a227c8da67ae97feb2 Mon Sep 17 00:00:00 2001 From: John Baldwin Date: Tue, 22 Apr 2008 17:03:32 +0000 Subject: [PATCH] Fix a leak in the recent fixes for file descriptors > SHRT_MAX. In the case of a file descriptor we can't handle, clear the FILE structure's flags so it can be reused. MFC after: 1 week Reported by: otto @ OpenBSD --- lib/libc/stdio/fopen.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/libc/stdio/fopen.c b/lib/libc/stdio/fopen.c index 14ec9bc5b72..6fe536a0c90 100644 --- a/lib/libc/stdio/fopen.c +++ b/lib/libc/stdio/fopen.c @@ -73,6 +73,7 @@ fopen(file, mode) * open. */ if (f > SHRT_MAX) { + fp->_flags = 0; /* release */ _close(f); errno = EMFILE; return (NULL);