sample: check allocation return
BUG=23200382 Change-Id: Ic64f76000d181f169af9aed2f7891f6ed3d28681
This commit is contained in:
parent
2dec09426a
commit
04d7809375
@ -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;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user