sample: check allocation return

BUG=23200382

Change-Id: Ic64f76000d181f169af9aed2f7891f6ed3d28681
This commit is contained in:
James Zern 2015-08-13 23:06:41 -07:00
parent 2dec09426a
commit 04d7809375

View File

@ -31,7 +31,9 @@ static const wchar_t* utf8towcs(const char* str) {
if (size == 0)
return NULL;
wchar_t* const val = new wchar_t[size + 1];
wchar_t* const val = new (std::nothrow) wchar_t[size + 1];
if (val == NULL)
return NULL;
mbstowcs(val, str, size);
val[size] = L'\0';
@ -353,4 +355,4 @@ int main(int argc, char* argv[]) {
fflush(stdout);
return 0;
}
}