]> Zhao Yanbai Git Server - minix.git/commitdiff
stdio/fclose.c: reset _buf
authorBen Gras <ben@minix3.org>
Tue, 2 Nov 2010 22:01:47 +0000 (22:01 +0000)
committerBen Gras <ben@minix3.org>
Tue, 2 Nov 2010 22:01:47 +0000 (22:01 +0000)
  - if the stream gets freopen()ed, avoid buffer being seen as valid

lib/libc/stdio/fclose.c

index 56bd0ac4a913fa43161138aff7927ef987f17180..85ecb420a3ac2ae3494ba76098419e5745c5c272 100644 (file)
@@ -25,6 +25,7 @@ fclose(FILE *fp)
        if (_close(fileno(fp))) retval = EOF;
        if ( io_testflag(fp,_IOMYBUF) && fp->_buf )
                free((void *)fp->_buf);
+       fp->_buf = NULL;
        if (fp != stdin && fp != stdout && fp != stderr)
                free((void *)fp);
        return retval;