X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/266b635a2862975cb4a470e72d6d4d2f8e637f14..ba5b8263f3bf5393eafcf185f5948f1554034ee1:/src/common/string.cpp diff --git a/src/common/string.cpp b/src/common/string.cpp index 9582bca6d9..280e105f25 100644 --- a/src/common/string.cpp +++ b/src/common/string.cpp @@ -200,7 +200,12 @@ extern int WXDLLEXPORT wxVsnprintf(wxChar *buf, size_t len, return iLen; #else // ANSI - return wxVsnprintfA(buf, len, format, argptr); + // vsnprintf() will not terminate the string with '\0' if there is not + // enough place, but we want the string to always be NUL terminated + int rc = wxVsnprintfA(buf, len - 1, format, argptr); + buf[len] = 0; + + return rc; #endif // Unicode/ANSI }