snprintf will add '\0' at the end itself.

This commit is contained in:
Egor Pugin 2021-03-14 23:54:29 +03:00 committed by GitHub
parent 26ceeef6c0
commit 262f65a4d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -436,7 +436,7 @@ bool ErrorCounter::ReportString(bool even_if_empty, const Counts &counts, std::s
"Answers=%.3g, Rank=%.3g, "
"OKjunk=%.4g%%, Badjunk=%.4g%%";
constexpr size_t max_str_len = sizeof(format_str) + kMaxExtraLength * (CT_SIZE - 1) + 1;
char formatted_str[max_str_len] = { 0 };
char formatted_str[max_str_len];
snprintf(formatted_str, max_str_len, format_str, rates[CT_UNICHAR_TOP1_ERR] * 100.0,
rates[CT_UNICHAR_TOP2_ERR] * 100.0, rates[CT_UNICHAR_TOPN_ERR] * 100.0,
rates[CT_UNICHAR_TOPTOP_ERR] * 100.0, rates[CT_OK_MULTI_UNICHAR] * 100.0,