fix: copy va

This commit is contained in:
2025-11-29 18:32:34 +01:00
parent e123218787
commit 597e35bebd

View File

@@ -1,5 +1,6 @@
#pragma once #pragma once
#include "memory.hpp" #include "memory.hpp"
#include <cstdarg>
namespace utils::string namespace utils::string
{ {
@@ -28,7 +29,12 @@ namespace utils::string
while (true) 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 (res < 0) return nullptr; // Error
if (static_cast<std::size_t>(res) >= entry->size_) if (static_cast<std::size_t>(res) >= entry->size_)