From ae98f82feff9d9686a1b3a7cc8691be6e1a9d497 Mon Sep 17 00:00:00 2001
From: Roman Tokarev <rtokarev@corp.mail.ru>
Date: Wed, 1 Dec 2010 13:14:14 +0300
Subject: [PATCH] [core] fix tbuf_vprintf

---
 core/tbuf.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/core/tbuf.c b/core/tbuf.c
index c7f3037a35..92ad5fbb7d 100644
--- a/core/tbuf.c
+++ b/core/tbuf.c
@@ -155,6 +155,9 @@ void tbuf_vprintf(struct tbuf *b, const char *format, va_list ap)
 {
 	int printed_len;
 	size_t free_len = b->size - b->len;
+	va_list ap_copy;
+
+	va_copy(ap_copy, ap);
 
 	tbuf_assert(b);
 	printed_len = vsnprintf(((char *)b->data) + b->len, free_len, format, ap);
@@ -166,7 +169,7 @@ void tbuf_vprintf(struct tbuf *b, const char *format, va_list ap)
 	if (free_len <= printed_len) {
 		tbuf_ensure(b, printed_len + 1);
 		free_len = b->size - b->len - 1;
-		printed_len = vsnprintf(((char *)b->data) + b->len, free_len, format, ap);
+		printed_len = vsnprintf(((char *)b->data) + b->len, free_len, format, ap_copy);
 	}
 
 	b->len += printed_len;
-- 
GitLab