From ad87777fd32b808bdb51c68cf54a6f6446d2b341 Mon Sep 17 00:00:00 2001 From: Simon Kallweit Date: Thu, 24 Oct 2024 13:54:29 +0200 Subject: [PATCH] fix string::format --- src/core/string.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/string.h b/src/core/string.h index 25cd6cb3..e8b12d98 100644 --- a/src/core/string.h +++ b/src/core/string.h @@ -51,10 +51,10 @@ inline const char* convertArg(const std::string& arg) template std::string format(const char* format, Args&&... args) { - size_t size = snprintf(nullptr, 0, format, detail::convertArg(args)...) + 1; + size_t len = snprintf(nullptr, 0, format, detail::convertArg(args)...); std::string str; - str.resize(size); - snprintf(str.data(), size, format, detail::convertArg(args)...); + str.resize(len); + snprintf(str.data(), len + 1, format, detail::convertArg(args)...); return str; }