From d5d78920316491975a67f76578982b401cdfe71d Mon Sep 17 00:00:00 2001 From: Artem Zhidkov Date: Sun, 28 Jun 2020 23:10:10 +0300 Subject: [PATCH] Task #3237: Allow usage of accented characters in ObjectBrowser Fix crash in conversion to wstring. --- src/ModelAPI/ModelAPI_Tools.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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; -- 2.39.2