bufprintf: Add va_end() for our va_copy()
authorMatt Fleming <matt.fleming@intel.com>
Thu, 15 Nov 2012 20:39:30 +0000 (20:39 +0000)
committerMatt Fleming <matt.fleming@intel.com>
Thu, 15 Nov 2012 20:39:30 +0000 (20:39 +0000)
According to the stdarg(3) man page each invocation of va_copy()
should be paired with an invocation of va_end().

Cc: Erwan Velu <erwanaliasr1@gmail.com>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
com32/lib/bufprintf.c

index 939bcec..d281231 100644 (file)
@@ -17,8 +17,10 @@ int vbufprintf(struct print_buf *buf, const char *format, va_list ap)
        char *newbuf;
 
        newbuf = realloc(buf->buf, newsize);
-       if (!newbuf)
-           return -1;
+       if (!newbuf) {
+           rv = -1;
+           goto bail;
+       }
 
        buf->buf = newbuf;
        buf->size = newsize;
@@ -26,6 +28,8 @@ int vbufprintf(struct print_buf *buf, const char *format, va_list ap)
 
     rv = vsnprintf(buf->buf + buf->len, buf->size - buf->len, format, ap2);
     buf->len += rv;
+bail:
+    va_end(ap2);
     return rv;
 }