From: cycl0ne Date: Mon, 9 Jun 2014 11:22:45 +0000 (+0000) Subject: Memory leak on setvbuf. Since the buffer wasnt freed on fclose() X-Git-Url: https://pd.if.org/git/?p=pdclib.old;a=commitdiff_plain;h=798f3aed35f8ee4102804620de84e947bbd9b8b8 Memory leak on setvbuf. Since the buffer wasnt freed on fclose() --- diff --git a/functions/stdio/fclose.c b/functions/stdio/fclose.c index 9452413..bc8d852 100644 --- a/functions/stdio/fclose.c +++ b/functions/stdio/fclose.c @@ -55,6 +55,11 @@ int fclose( FILE * stream ) { remove( stream->filename ); } + /* Free user buffer (SetVBuf allocated) */ + if ( ! ( stream->status & _PDCLIB_FREEBUFFER ) ) + { + free( stream->buffer ); + } /* Free stream */ if ( ! ( stream->status & _PDCLIB_STATIC ) ) {