X-Git-Url: https://git.saurik.com/apple/libc.git/blobdiff_plain/1f2f436a38f7ae2d39a943ad2898d8fed4ed2e58..6dccf0e0b5e80b7b6176e8d332e646175431bb3d:/stdio/FreeBSD/fclose.c diff --git a/stdio/FreeBSD/fclose.c b/stdio/FreeBSD/fclose.c index e80edcf..e38bbbf 100644 --- a/stdio/FreeBSD/fclose.c +++ b/stdio/FreeBSD/fclose.c @@ -49,6 +49,12 @@ fclose(FILE *fp) { int r; + pthread_once(&__sdidinit, __sinit); + + if (fp == NULL) { + errno = EFAULT; + return (EOF); + } if (fp->_flags == 0) { /* not open! */ errno = EBADF; return (EOF); @@ -65,7 +71,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. */ FUNLOCKFILE(fp); + __sfprelease(fp); /* Release this FILE for reuse. */ return (r); }