From 58749473819751517dcda1173551948ae87c5a2e Mon Sep 17 00:00:00 2001 From: diamante0018 Date: Mon, 19 Jan 2026 15:37:39 +0100 Subject: [PATCH] fix: string util --- src/common/utils/string.hpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/common/utils/string.hpp b/src/common/utils/string.hpp index e9e5860..1d5cc5d 100644 --- a/src/common/utils/string.hpp +++ b/src/common/utils/string.hpp @@ -1,5 +1,6 @@ #pragma once #include "memory.hpp" +#include #include template @@ -29,7 +30,12 @@ namespace utils::string while (true) { - const auto res = vsnprintf_s(entry->buffer_, entry->size_, _TRUNCATE, format, ap); + va_list ap_copy; + va_copy(ap_copy, ap); + + const auto res = vsnprintf_s(entry->buffer_, entry->size_, _TRUNCATE, format, ap_copy); + va_end(ap_copy); + if (res > 0) break; // Success if (res == 0) return nullptr; // Error