From 6f50d20ba362315dea4ecaf44336c3aaa4284975 Mon Sep 17 00:00:00 2001 From: Matt Fleming Date: Thu, 15 Nov 2012 20:39:30 +0000 Subject: [PATCH] bufprintf: Add va_end() for our va_copy() According to the stdarg(3) man page each invocation of va_copy() should be paired with an invocation of va_end(). Cc: Erwan Velu Signed-off-by: Matt Fleming --- com32/lib/bufprintf.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/com32/lib/bufprintf.c b/com32/lib/bufprintf.c index 939bcec..d281231 100644 --- a/com32/lib/bufprintf.c +++ b/com32/lib/bufprintf.c @@ -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; } -- 2.7.4