From 68c4f99b29a758d29ec301e2de8236a88a55c6df Mon Sep 17 00:00:00 2001 From: Richard Nyberg Date: Wed, 8 Nov 2006 14:29:10 +0000 Subject: [PATCH] Fix evbuffer_add_vprintf. Patch taken from . --- libevent/buffer.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libevent/buffer.c b/libevent/buffer.c index e09cc3d..1585389 100644 --- a/libevent/buffer.c +++ b/libevent/buffer.c @@ -132,17 +132,20 @@ evbuffer_add_vprintf(struct evbuffer *buf, const char *fmt, va_list ap) size_t space; size_t oldoff = buf->off; int sz; + va_list aq; for (;;) { buffer = buf->buffer + buf->off; space = buf->totallen - buf->misalign - buf->off; + va_copy(aq, ap); #ifdef WIN32 - sz = vsnprintf(buffer, space - 1, fmt, ap); + sz = vsnprintf(buffer, space - 1, fmt, aq); buffer[space - 1] = '\0'; #else - sz = vsnprintf(buffer, space, fmt, ap); + sz = vsnprintf(buffer, space, fmt, aq); #endif + va_end(aq); if (sz == -1) return (-1); if (sz < space) {