From 84287b831ecbe105cea14294c8f5b058546ce801 Mon Sep 17 00:00:00 2001 From: Darren Tucker Date: Fri, 14 Sep 2007 10:04:15 +1000 Subject: [PATCH] - (dtucker) [openbsd-compat/bsd-asprintf.c] Plug mem leak in error path. Patch from Jan.Pechanec at sun com. --- ChangeLog | 6 +++++- openbsd-compat/bsd-asprintf.c | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 7d92bff91..fa6eb1c6e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +20070914 + - (dtucker) [openbsd-compat/bsd-asprintf.c] Plug mem leak in error path. + Patch from Jan.Pechanec at sun com. + 20070910 - (dtucker) [openbsd-compat/regress/closefromtest.c] Bug #1358: Always return 0 on successful test. From David.Leonard at quest com. @@ -3190,4 +3194,4 @@ OpenServer 6 and add osr5bigcrypt support so when someone migrates passwords between UnixWare and OpenServer they will still work. OK dtucker@ -$Id: ChangeLog,v 1.4741 2007/09/10 23:24:17 tim Exp $ +$Id: ChangeLog,v 1.4742 2007/09/14 00:04:15 dtucker Exp $ 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;