fix: copy va

This commit is contained in:
2025-11-29 18:42:25 +01:00
parent 6494d7be1d
commit 250cc1e806

View File

@@ -1,5 +1,6 @@
#pragma once
#include "memory.hpp"
#include <cstdarg>
template <class Type, std::size_t n>
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<std::size_t>(res) >= entry->size_)