summaryrefslogtreecommitdiff
path: root/src/til_str.c
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2023-06-25 21:29:38 -0700
committerVito Caputo <vcaputo@pengaru.com>2023-07-04 21:09:16 -0700
commit8fc32619d8e63518ee8e205da9f96e274e178b2d (patch)
treeef3690f24dee566760e64d6edc8ba2930d264520 /src/til_str.c
parent5fd4e4331baf62d17632b2627db202459e8be6b0 (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
Diffstat (limited to 'src/til_str.c')
-rw-r--r--src/til_str.c5
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);
© All Rights Reserved