vis

a vi-like editor based on Plan 9's structural regular expressions

git clone https://9o.is/git/vis.git

commit 0e4b450d4a6a0460b4ab76f105b52fa06eebdfe0
parent 3e2b6c41b98871f8913b6379231878a073dca9be
Author: David B. Lamkins <dlamkins@galois.com>
Date:   Fri,  9 Oct 2015 10:35:02 +0200

text: fix usage of va_arg in text_vprintf

Closes #76

Diffstat:
Mtext.c | 5++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/text.c b/text.c @@ -643,12 +643,15 @@ bool text_printf(Text *txt, size_t pos, const char *format, ...) { } bool text_vprintf(Text *txt, size_t pos, const char *format, va_list ap) { + va_list ap_save; + va_copy(ap_save, ap); int len = vsnprintf(NULL, 0, format, ap); if (len == -1) return false; char *buf = malloc(len+1); - bool ret = buf && (vsnprintf(buf, len+1, format, ap) == len) && text_insert(txt, pos, buf, len); + bool ret = buf && (vsnprintf(buf, len+1, format, ap_save) == len) && text_insert(txt, pos, buf, len); free(buf); + va_end(ap_save); return ret; }