]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Task #3237: Allow usage of accented characters in ObjectBrowser
authorArtem Zhidkov <Artem.Zhidkov@opencascade.com>
Sun, 28 Jun 2020 20:10:10 +0000 (23:10 +0300)
committerArtem Zhidkov <Artem.Zhidkov@opencascade.com>
Sun, 28 Jun 2020 20:10:10 +0000 (23:10 +0300)
Fix crash in conversion to wstring.

src/ModelAPI/ModelAPI_Tools.cpp

index e0da11a2f9490ae9ba3e5bb452a64955ff599bd2..8922813f0e401fc32c4ab68b3d481b80fd022611 100644 (file)
@@ -1142,10 +1142,10 @@ std::wstring toWString(const std::string& theStr)
   static std::wstring_convert<std::codecvt_utf8<wchar_t> > 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;