Skip to content

Commit

Permalink
fix string::format
Browse files Browse the repository at this point in the history
  • Loading branch information
skallweitNV committed Oct 24, 2024
1 parent 6386188 commit ad87777
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/core/string.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ inline const char* convertArg(const std::string& arg)
template<typename... Args>
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;
}

Expand Down

0 comments on commit ad87777

Please sign in to comment.