From 250cc1e806f2b94696d0626ce2158c21a99961fa Mon Sep 17 00:00:00 2001 From: diamante0018 Date: Sat, 29 Nov 2025 18:42:25 +0100 Subject: [PATCH] fix: copy va --- src/utils/string.hpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/utils/string.hpp b/src/utils/string.hpp index c704f2b..814b5ac 100644 --- a/src/utils/string.hpp +++ b/src/utils/string.hpp @@ -1,5 +1,6 @@ #pragma once #include "memory.hpp" +#include template constexpr auto ARRAY_COUNT(Type(&)[n]) { return n; } @@ -30,7 +31,12 @@ namespace utils while (true) { - const auto res = vsnprintf(entry->buffer_, entry->size_, format, ap); + va_list ap_copy; + va_copy(ap_copy, ap); + + const auto res = vsnprintf(entry->buffer_, entry->size_, format, ap_copy); + va_end(ap_copy); + if (res < 0) return nullptr; // Error if (static_cast(res) >= entry->size_)