diff --git a/src/common/strconv.cpp b/src/common/strconv.cpp index c3191201c4..3102294183 100644 --- a/src/common/strconv.cpp +++ b/src/common/strconv.cpp @@ -488,7 +488,12 @@ wxMBConv::cWC2MB(const wchar_t *inBuff, size_t inLen, size_t *outLen) const // the input is not wxCharBuffer buf(dstLen + nulLen - 1); memset(buf.data() + dstLen, 0, nulLen); - if ( FromWChar(buf.data(), dstLen, inBuff, inLen) != wxCONV_FAILED ) + + // Notice that return value of the call to FromWChar() here may be + // different from the one above as it could have overestimated the + // space needed, while what we get here is the exact length. + dstLen = FromWChar(buf.data(), dstLen, inBuff, inLen); + if ( dstLen != wxCONV_FAILED ) { if ( outLen ) {