aboutsummaryrefslogtreecommitdiff
path: root/text.c
diff options
context:
space:
mode:
authorDavid B. Lamkins <dlamkins@galois.com>2015-10-09 10:35:02 +0200
committerMarc André Tanner <mat@brain-dump.org>2015-10-09 10:35:02 +0200
commitdb7c309c8bb09c5de0dcd5de9a7fab7e0e143876 (patch)
treece13c09365ca6801c836b1e7ada7399b1fa69729 /text.c
parent6550d807ccf7149286b03083590d3f1c12141a32 (diff)
downloadvis-db7c309c8bb09c5de0dcd5de9a7fab7e0e143876.tar.gz
vis-db7c309c8bb09c5de0dcd5de9a7fab7e0e143876.tar.xz
text: fix usage of va_arg in text_vprintf
Closes #76
Diffstat (limited to 'text.c')
-rw-r--r--text.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/text.c b/text.c
index 94a32f9..0bcf173 100644
--- 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;
}