about summary refs log tree commit diff
path: root/libio
diff options
context:
space:
mode:
Diffstat (limited to 'libio')
-rw-r--r--libio/vasprintf.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/libio/vasprintf.c b/libio/vasprintf.c
index 1cab48512e..2e27e82687 100644
--- a/libio/vasprintf.c
+++ b/libio/vasprintf.c
@@ -60,7 +60,10 @@ _IO_vasprintf (result_ptr, format, args)
   sf._s._free_buffer = (_IO_free_type) free;
   ret = _IO_vfprintf (&sf._sbf._f, format, args);
   if (ret < 0)
-    return ret;
+    {
+      free (sf._sbf._f._IO_buf_base);
+      return ret;
+    }
   /* Only use realloc if the size we need is of the same order of
      magnitude then the memory we allocated.  */
   needed = sf._sbf._f._IO_write_ptr - sf._sbf._f._IO_write_base + 1;