cmark

My personal build of CMark ✏️

Commit
834266acfdb2aa63e07ae03b08ae11ca21e00dcf
Parent
1cea53dbc7b87434184c8a9a0901be5ea5a9c5a0
Author
John MacFarlane <jgm@berkeley.edu>
Date

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?

Diffstat

1 file changed, 4 insertions, 1 deletion

Status File Name N° Changes Insertions Deletions
Modified src/buffer.c 5 4 1
diff --git 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) {