diff options
author | Vito Caputo <vcaputo@pengaru.com> | 2023-06-25 21:29:38 -0700 |
---|---|---|
committer | Vito Caputo <vcaputo@pengaru.com> | 2023-07-04 21:09:16 -0700 |
commit | 8fc32619d8e63518ee8e205da9f96e274e178b2d (patch) | |
tree | ef3690f24dee566760e64d6edc8ba2930d264520 | |
parent | 5fd4e4331baf62d17632b2627db202459e8be6b0 (diff) |
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
-rw-r--r-- | src/til_str.c | 5 |
1 files 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); |