[10108] Prevent access to out of range [0] element of empty string at utf8 convertion.

This commit is contained in:
VladimirMangos 2010-06-26 22:38:38 +04:00
parent 4e1c8a2ad6
commit 698fe93eb7
2 changed files with 3 additions and 2 deletions

View file

@ -297,7 +297,8 @@ bool Utf8toWStr(const std::string& utf8str, std::wstring& wstr)
size_t len = utf8::distance(utf8str.c_str(),utf8str.c_str()+utf8str.size());
wstr.resize(len);
utf8::utf8to16(utf8str.c_str(),utf8str.c_str()+utf8str.size(),&wstr[0]);
if (len)
utf8::utf8to16(utf8str.c_str(),utf8str.c_str()+utf8str.size(),&wstr[0]);
}
catch(std::exception)
{