From: Artem Zhidkov Date: Sun, 28 Jun 2020 20:10:10 +0000 (+0300) Subject: Task #3237: Allow usage of accented characters in ObjectBrowser X-Git-Tag: V9_6_0a1~60^2~20 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=d5d78920316491975a67f76578982b401cdfe71d;p=modules%2Fshaper.git Task #3237: Allow usage of accented characters in ObjectBrowser Fix crash in conversion to wstring. --- diff --git a/src/ModelAPI/ModelAPI_Tools.cpp b/src/ModelAPI/ModelAPI_Tools.cpp index e0da11a2f..8922813f0 100644 --- a/src/ModelAPI/ModelAPI_Tools.cpp +++ b/src/ModelAPI/ModelAPI_Tools.cpp @@ -1142,10 +1142,10 @@ std::wstring toWString(const std::string& theStr) static std::wstring_convert > aConvertor; return aConvertor.from_bytes(theStr); #else - wchar_t* aBuf = new wchar_t[theStr.size()]; + wchar_t* aBuf = new wchar_t[theStr.size() + 1]; size_t aNbWChars = std::mbstowcs(aBuf, theStr.c_str(), theStr.size()); if (aNbWChars != (size_t)-1) - aBuf[aNbWChars] = '\0'; + aBuf[aNbWChars] = L'\0'; std::wstring aWStr(aBuf); delete[] aBuf; return aWStr;