From 8fc32619d8e63518ee8e205da9f96e274e178b2d Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Sun, 25 Jun 2023 21:29:38 -0700 Subject: til_str: fix va_start/va_end usage in til_str_newf() You can't just reuse the ap in multiple calls to vsnprintf without restarting... fixed in the obvious way --- src/til_str.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/til_str.c b/src/til_str.c index 442e923..f3cc5e8 100644 --- a/src/til_str.c +++ b/src/til_str.c @@ -88,14 +88,15 @@ til_str_t * til_str_newf(const char *format, ...) assert(format); - va_start(ap, format); + va_start(ap, format); str = til_str_nulstr(vsnprintf(NULL, 0, format, ap) + 1); + va_end(ap); if (!str) return NULL; + va_start(ap, format); str->size.used += vsnprintf(str->buf, str->size.allocated, format, ap); - va_end(ap); assert(str->size.used <= str->size.allocated); -- cgit v1.2.3