emilib
emilib copied to clipboard
Usage of vsnprintf() drops last character
vsnprintf() expects a string of size _BufferCount - 1 because it always appends a null terminator (see https://www.cplusplus.com/reference/cstdio/vsnprintf/). This causes strprintf() to drop the last character.
A tested fix with Visual Studio 2022 is using bytes_needed + 1:
https://github.com/emilk/emilib/blob/0d90f4c0cd44813f6898b417bf3f4ef574a5b136/emilib/strprintf.cpp#L20