aboutsummaryrefslogtreecommitdiff
path: root/libio/vasprintf.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2001-12-06 08:49:08 +0000
committerUlrich Drepper <drepper@redhat.com>2001-12-06 08:49:08 +0000
commit383bd1c5033b466ffcc1a0be766d8a8b003c73e9 (patch)
tree06aec2446da55eee38518fb8296728d0910f258d /libio/vasprintf.c
parent1e06620a7b9c6c65284c52b4625eabd23b14c77c (diff)
downloadglibc-383bd1c5033b466ffcc1a0be766d8a8b003c73e9.zip
glibc-383bd1c5033b466ffcc1a0be766d8a8b003c73e9.tar.gz
glibc-383bd1c5033b466ffcc1a0be766d8a8b003c73e9.tar.bz2
Update.
2001-12-06 Ulrich Drepper <drepper@redhat.com> * libio/vasprintf.c (_IO_vasprintf): Free buffer on failure. * assert/assert.c: Check result of __asprintf call and don't use string if it failed. * assert/assert-perr.c: Likewise. * inet/rcmd.c: Likewise. * locale/programs/localedef.c (main): Check result of construct_output_path and exit if it failed. (construct_output_path): Check result of asprintf and mkdir calls and fail if they failed. * posix/getopt.c: Check result of __asprintf calls and fail if they failed. Patch by Dmitry V. Levin <ldv@alt-linux.org>.
Diffstat (limited to 'libio/vasprintf.c')
-rw-r--r--libio/vasprintf.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/libio/vasprintf.c b/libio/vasprintf.c
index 1cab485..2e27e82 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;