From 834266acfdb2aa63e07ae03b08ae11ca21e00dcf Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Tue, 30 Dec 2014 15:00:32 -0800 Subject: Revert "Remove unneeded va_copy" This reverts commit 485ef21b95e257e9d9cbcaa804c3c164f1f49a80. Apparently the va_copy IS needed, because without this code we get segfaults in some cases. Closes #253. @nwellnhof, can you have a look at this issue and comment? I understand that this code was removed for portability reasons. Is there an alternative solution? --- src/buffer.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/buffer.c') diff --git a/src/buffer.c b/src/buffer.c index f273f45..b508310 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -166,10 +166,13 @@ int cmark_strbuf_vprintf(cmark_strbuf *buf, const char *format, va_list ap) ENSURE_SIZE(buf, expected_size); while (1) { + va_list args; + va_copy(args, ap); + len = vsnprintf( (char *)buf->ptr + buf->size, buf->asize - buf->size, - format, ap + format, args ); if (len < 0) { -- cgit v1.2.3