sample: check allocation return
BUG=23200382 Change-Id: Ic64f76000d181f169af9aed2f7891f6ed3d28681
This commit is contained in:
@@ -31,7 +31,9 @@ static const wchar_t* utf8towcs(const char* str) {
|
|||||||
if (size == 0)
|
if (size == 0)
|
||||||
return NULL;
|
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);
|
mbstowcs(val, str, size);
|
||||||
val[size] = L'\0';
|
val[size] = L'\0';
|
||||||
@@ -353,4 +355,4 @@ int main(int argc, char* argv[]) {
|
|||||||
|
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user