sample: correct mbstowcs() error check

mbstowcs() can return (size_t)-1 if it encounters an invalid string

BUG=23200382

Change-Id: Ibf67145be3989e16cd24c06850c7a5aa581a0ada
This commit is contained in:
James Zern
2015-08-14 10:57:48 -07:00
parent 04d7809375
commit 82b7e5f487

View File

@@ -28,7 +28,7 @@ static const wchar_t* utf8towcs(const char* str) {
const size_t size = mbstowcs(NULL, str, 0);
if (size == 0)
if (size == 0 || size == static_cast<size_t>(-1))
return NULL;
wchar_t* const val = new (std::nothrow) wchar_t[size + 1];