X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/0dd13d21cd03499e1d8e86a22d0841b900bf2c8d..cba7320c9cb0774cacf7001960af3b4bd13f9a9c:/src/common/strconv.cpp diff --git a/src/common/strconv.cpp b/src/common/strconv.cpp index 65f6cb7eee..3e354f466b 100644 --- a/src/common/strconv.cpp +++ b/src/common/strconv.cpp @@ -395,6 +395,7 @@ wxMBConv::cMB2WC(const char *inBuff, size_t inLen, size_t *outLen) const // because we want the buffer to always be NUL-terminated, even if the // input isn't (as otherwise the caller has no way to know its length) wxWCharBuffer wbuf(dstLen); + wbuf.data()[dstLen - 1] = L'\0'; if ( ToWChar(wbuf.data(), dstLen, inBuff, inLen) != wxCONV_FAILED ) { if ( outLen ) @@ -2456,8 +2457,10 @@ public: return wxCONV_FAILED; } + if ( !n ) + n = wcslen(pwz); wxWCharBuffer wcBuf(n); - if ( MB2WC(wcBuf.data(), buf, n) == wxCONV_FAILED || + if ( MB2WC(wcBuf.data(), buf, n + 1) == wxCONV_FAILED || wcscmp(wcBuf, pwz) != 0 ) { // we didn't obtain the same thing we started from, hence