From 70428c1859bf6ab575489567dd696c837e973f75 Mon Sep 17 00:00:00 2001 From: jjohnstn Date: Fri, 16 Jul 2004 15:47:14 +0000 Subject: [PATCH] 2004-07-16 Jeff Johnston * libc/stdio/fvwrite.c (_sfvwrite): For asprintf family calls, if realloc fails, free up buffer as it is no longer used. --- newlib/ChangeLog | 6 ++++++ newlib/libc/stdio/fvwrite.c | 6 +++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/newlib/ChangeLog b/newlib/ChangeLog index 4c0d460adc..faaf1255cb 100644 --- a/newlib/ChangeLog +++ b/newlib/ChangeLog @@ -1,3 +1,9 @@ +2004-07-16 Jeff Johnston + + * libc/stdio/fvwrite.c (_sfvwrite): For asprintf family + calls, if realloc fails, free up buffer as it is no longer + used. + 2004-07-07 Artem B. Bityuckiy * libc/iconv/iconv.tex: Updated to represent recent changes. diff --git a/newlib/libc/stdio/fvwrite.c b/newlib/libc/stdio/fvwrite.c index 3143b01b51..f036d7483d 100644 --- a/newlib/libc/stdio/fvwrite.c +++ b/newlib/libc/stdio/fvwrite.c @@ -129,7 +129,11 @@ _DEFUN(__sfvwrite, (fp, uio), fp->_bf._base, curpos + len); if (!ptr) - goto err; + { + /* Free buffer which is no longer used. */ + _free_r (_REENT, fp->_bf._base); + goto err; + } fp->_bf._base = ptr; fp->_p = ptr + curpos; fp->_bf._size = curpos + len; -- 2.11.0