summaryrefslogtreecommitdiffstats
path: root/newlib/libc/stdio/fvwrite.c
diff options
context:
space:
mode:
Diffstat (limited to 'newlib/libc/stdio/fvwrite.c')
-rw-r--r--newlib/libc/stdio/fvwrite.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/newlib/libc/stdio/fvwrite.c b/newlib/libc/stdio/fvwrite.c
index f196b3cfe..384c62ce0 100644
--- a/newlib/libc/stdio/fvwrite.c
+++ b/newlib/libc/stdio/fvwrite.c
@@ -155,8 +155,10 @@ _DEFUN(__sfvwrite_r, (ptr, fp, uio),
newsize);
if (!str)
{
- /* Free buffer which is no longer used. */
+ /* Free buffer which is no longer used and clear
+ __SMBF flag to avoid double free in fclose. */
_free_r (ptr, fp->_bf._base);
+ fp->_flags &= ~__SMBF;
/* Ensure correct errno, even if free changed it. */
ptr->_errno = ENOMEM;
goto err;