Fixed bug in potential reuse of args in vsnprintf

This commit is contained in:
Dmitry Boulytchev 2021-12-03 03:56:58 +03:00
parent 669a4288d7
commit f953814c76
3 changed files with 12 additions and 6 deletions

View file

@ -421,11 +421,17 @@ static void vprintStringBuf (char *fmt, va_list args) {
int written = 0, int written = 0,
rest = 0; rest = 0;
char *buf = (char*) BOX(NULL); char *buf = (char*) BOX(NULL);
va_list vsnargs;
again: again:
va_copy (vsnargs, args);
buf = &stringBuf.contents[stringBuf.ptr]; buf = &stringBuf.contents[stringBuf.ptr];
rest = stringBuf.len - stringBuf.ptr; rest = stringBuf.len - stringBuf.ptr;
written = vsnprintf (buf, rest, fmt, args);
written = vsnprintf (buf, rest, fmt, vsnargs);
va_end(vsnargs);
if (written >= rest) { if (written >= rest) {
extendStringBuf (); extendStringBuf ();

View file

@ -1 +1 @@
let version = "Version 1.10, eb098a6fa, Sun Oct 31 15:34:34 2021 +0300" let version = "Version 1.10, 669a4288d, Mon Nov 22 15:51:47 2021 +0300"

View file

@ -2,7 +2,7 @@ SHELL := /bin/bash
FILES=$(wildcard *.lama) FILES=$(wildcard *.lama)
ALL=$(sort $(FILES:.lama=.o)) ALL=$(sort $(FILES:.lama=.o))
LAMAC=../src/lamac -ds LAMAC=../src/lamac -g
all: $(ALL) all: $(ALL)