diff --git a/libc/stdio/__fopen.c b/libc/stdio/__fopen.c index 4ab66cafa..236111baf 100644 --- a/libc/stdio/__fopen.c +++ b/libc/stdio/__fopen.c @@ -74,11 +74,6 @@ __fopen(const char * fname, int fd, FILE * fp, const char * mode) break; } - if (!fname) { - errno = EINVAL; - return 0; - } - /* Allocate the (FILE) before we do anything irreversable */ if (fp == 0) { @@ -88,7 +83,8 @@ __fopen(const char * fname, int fd, FILE * fp, const char * mode) } /* Open the file itself */ - fd = open(fname, open_mode, 0666); + if (fname) + fd = open(fname, open_mode, 0666); if (fd < 0) /* Grrrr */ { if (nfp) diff --git a/libc/stdio/fopen.c b/libc/stdio/fopen.c index 703308c8b..2c07a8b25 100644 --- a/libc/stdio/fopen.c +++ b/libc/stdio/fopen.c @@ -1,6 +1,11 @@ #include +#include FILE * fopen (const char * file, const char * mode) { - return __fopen(file, -1, (FILE*)0, mode); + if (file == NULL) { + errno = EINVAL; + return 0; + } + return __fopen(file, -1, (FILE *)0, mode); }