summaryrefslogtreecommitdiffstatshomepage
path: root/py/vstr.c
diff options
context:
space:
mode:
authorJohn R. Lenton <jlenton@gmail.com>2014-01-03 22:55:16 +0000
committerJohn R. Lenton <jlenton@gmail.com>2014-01-03 22:55:16 +0000
commit97334c85d0b53ef1648eb76ec6e9e2b1efab1f97 (patch)
treed10f6b6b7ca3394e6f7dc31ca55e0df2b39abe02 /py/vstr.c
parent25f417c08c2cdb5c4a7564d1e69766c0448d7984 (diff)
parentb7aa72710ee6798c6d2bc2632be24206e526fc1e (diff)
downloadmicropython-97334c85d0b53ef1648eb76ec6e9e2b1efab1f97.tar.gz
micropython-97334c85d0b53ef1648eb76ec6e9e2b1efab1f97.zip
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'py/vstr.c')
-rw-r--r--py/vstr.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/py/vstr.c b/py/vstr.c
index 98cf027250..80841b24ca 100644
--- a/py/vstr.c
+++ b/py/vstr.c
@@ -167,8 +167,12 @@ void vstr_vprintf(vstr_t *vstr, const char *fmt, va_list ap) {
while (1) {
// try to print in the allocated space
+ // need to make a copy of the va_list because we may call vsnprintf multiple times
int size = vstr->alloc - vstr->len;
- int n = vsnprintf(vstr->buf + vstr->len, size, fmt, ap);
+ va_list ap2;
+ va_copy(ap2, ap);
+ int n = vsnprintf(vstr->buf + vstr->len, size, fmt, ap2);
+ va_end(ap2);
// if that worked, return
if (n > -1 && n < size) {