Pass the correct va_list to vsnprintf().

This commit is contained in:
Dag-Erling Smørgrav 2017-04-29 02:12:27 +02:00
parent 5da37869f2
commit e99877752f

View file

@ -302,7 +302,7 @@ string_printf(string *str, const char_t *fmt, ...)
ssize_t ssize_t
string_vprintf(string *str, const char_t *fmt, va_list ap) string_vprintf(string *str, const char_t *fmt, va_list ap)
{ {
va_list ap2; va_list apc;
ssize_t res, ret; ssize_t res, ret;
int len; int len;
@ -312,9 +312,9 @@ string_vprintf(string *str, const char_t *fmt, va_list ap)
*/ */
for (;;) { for (;;) {
res = str->size / sizeof(char_t) - str->len; res = str->size / sizeof(char_t) - str->len;
va_copy(ap2, ap); va_copy(apc, ap);
len = vsnprintf(str->buf + str->len, res, fmt, ap); len = vsnprintf(str->buf + str->len, res, fmt, apc);
va_end(ap2); va_end(apc);
if (len < res) if (len < res)
break; break;
str->buf[str->len] = 0; str->buf[str->len] = 0;