X-Git-Url: https://git.saurik.com/apple/libc.git/blobdiff_plain/7b00c0c43f52e9d27168e67a26aac19065cdb40c..ad3c9f2af814c84582fdd1649e49ec4f68572c5a:/stdio/FreeBSD/fclose.c diff --git a/stdio/FreeBSD/fclose.c b/stdio/FreeBSD/fclose.c index e80edcf..91df68a 100644 --- a/stdio/FreeBSD/fclose.c +++ b/stdio/FreeBSD/fclose.c @@ -49,6 +49,13 @@ fclose(FILE *fp) { int r; + if (!__sdidinit) + __sinit(); + + if (fp == NULL) { + errno = EFAULT; + return (EOF); + } if (fp->_flags == 0) { /* not open! */ errno = EBADF; return (EOF); @@ -65,7 +72,7 @@ fclose(FILE *fp) FREELB(fp); fp->_file = -1; fp->_r = fp->_w = 0; /* Mess up if reaccessed. */ - fp->_flags = 0; /* Release this FILE for reuse. */ + __sfprelease(fp); /* Release this FILE for reuse. */ FUNLOCKFILE(fp); return (r); }