[syslinux:elflink] asprintf: Ensure we always call va_end(ap)

syslinux-bot for Matt Fleming matt.fleming at intel.com
Tue Nov 27 14:15:03 PST 2012


Commit-ID:  3da9e71f9ffa0ca968ccfcf26d536908d198ef5c
Gitweb:     http://www.syslinux.org/commit/3da9e71f9ffa0ca968ccfcf26d536908d198ef5c
Author:     Matt Fleming <matt.fleming at intel.com>
AuthorDate: Thu, 15 Nov 2012 20:56:09 +0000
Committer:  Matt Fleming <matt.fleming at intel.com>
CommitDate: Thu, 15 Nov 2012 20:56:09 +0000

asprintf: Ensure we always call va_end(ap)

There's currently the potential for us to exit early from asprintf()
without calling va_end(ap). Rearrange things so that we always make
the call.

Signed-off-by: Matt Fleming <matt.fleming at intel.com>

---
 com32/lib/asprintf.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/com32/lib/asprintf.c b/com32/lib/asprintf.c
index ef5b4b2..eab2011 100644
--- a/com32/lib/asprintf.c
+++ b/com32/lib/asprintf.c
@@ -21,9 +21,10 @@ int asprintf(char **bufp, const char *format, ...)
 
     *bufp = p = malloc(bytes);
     if (!p)
-	return -1;
+	rv = -1;
+    else
+	rv = vsnprintf(p, bytes, format, ap);
 
-    rv = vsnprintf(p, bytes, format, ap);
     va_end(ap);
 
     return rv;


More information about the Syslinux-commits mailing list