emilib icon indicating copy to clipboard operation
emilib copied to clipboard

Usage of vsnprintf() drops last character

Open grimfang4 opened this issue 4 years ago • 0 comments

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

grimfang4 avatar May 09 '22 16:05 grimfang4