Handle null terminator at the end of the buffer

This commit is contained in:
Victor Zverovich
2019-11-24 06:38:01 -08:00
parent 63a9f3fcd4
commit 43271ba8e8
2 changed files with 24 additions and 18 deletions

View File

@@ -1159,7 +1159,8 @@ int snprintf_float(T value, int precision, float_spec spec, buffer<char>& buf) {
continue;
}
unsigned size = to_unsigned(result);
if (size > capacity) {
// Size equal to capacity means that the last character was truncated.
if (size >= capacity) {
buf.reserve(size + 1); // Add 1 for the terminating '\0'.
continue;
}