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:
@@ -28,7 +28,7 @@ static const wchar_t* utf8towcs(const char* str) {
|
|||||||
|
|
||||||
const size_t size = mbstowcs(NULL, str, 0);
|
const size_t size = mbstowcs(NULL, str, 0);
|
||||||
|
|
||||||
if (size == 0)
|
if (size == 0 || size == static_cast<size_t>(-1))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
wchar_t* const val = new (std::nothrow) wchar_t[size + 1];
|
wchar_t* const val = new (std::nothrow) wchar_t[size + 1];
|
||||||
|
|||||||
Reference in New Issue
Block a user