Skip to content

Commit 07f54e7

Browse files
committed
fix: copy va
1 parent 3231438 commit 07f54e7

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/utils/string.hpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#pragma once
22
#include "memory.hpp"
3+
#include <cstdarg>
34
#include <cstdint>
45

56
template <class Type, std::size_t n>
@@ -29,7 +30,12 @@ namespace utils::string
2930

3031
while (true)
3132
{
32-
const auto res = vsnprintf(entry->buffer_, entry->size_, format, ap);
33+
va_list ap_copy;
34+
va_copy(ap_copy, ap);
35+
36+
const auto res = vsnprintf(entry->buffer_, entry->size_, format, ap_copy);
37+
va_end(ap_copy);
38+
3339
if (res < 0) return nullptr; // Error
3440

3541
if (static_cast<std::size_t>(res) >= entry->size_)

0 commit comments

Comments
 (0)