summaryrefslogtreecommitdiffstats
path: root/openbsd-compat/bsd-asprintf.c
diff options
context:
space:
mode:
authorDarren Tucker <dtucker@zip.com.au>2007-09-14 02:04:15 +0200
committerDarren Tucker <dtucker@zip.com.au>2007-09-14 02:04:15 +0200
commit84287b831ecbe105cea14294c8f5b058546ce801 (patch)
tree5ab544c7af4f5255c4f465b37a2099c646d58983 /openbsd-compat/bsd-asprintf.c
parent - (tim) [configure.ac] Autoconf didn't define HAVE_LIBIAF because we (diff)
downloadopenssh-84287b831ecbe105cea14294c8f5b058546ce801.tar.xz
openssh-84287b831ecbe105cea14294c8f5b058546ce801.zip
- (dtucker) [openbsd-compat/bsd-asprintf.c] Plug mem leak in error path.
Patch from Jan.Pechanec at sun com.
Diffstat (limited to 'openbsd-compat/bsd-asprintf.c')
-rw-r--r--openbsd-compat/bsd-asprintf.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/openbsd-compat/bsd-asprintf.c b/openbsd-compat/bsd-asprintf.c
index 00fa0dfd8..3368195d4 100644
--- a/openbsd-compat/bsd-asprintf.c
+++ b/openbsd-compat/bsd-asprintf.c
@@ -55,6 +55,7 @@ vasprintf(char **str, const char *fmt, va_list ap)
if (ret >= 0 && ret < INIT_SZ) { /* succeeded with initial alloc */
*str = string;
} else if (ret == INT_MAX || ret < 0) { /* Bad length */
+ free(string);
goto fail;
} else { /* bigger than initial, realloc allowing for nul */
len = (size_t)ret + 1;