Skip to content

Commit

Permalink
check memory allocation failure
Browse files Browse the repository at this point in the history
  • Loading branch information
FrankYFTang committed Feb 1, 2020
1 parent 42ba23c commit 18ba9f6
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions icu4c/source/test/intltest/ustrtest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2350,6 +2350,10 @@ void UnicodeStringTest::TestLargeAppend() {
UnicodeString str2;
int32_t remain = INT32_MAX - total;
char16_t *buf2 = str2.getBuffer(remain);
if (buf2 == nullptr) {
// if somehow memory allocation fail, return the test
return;
}
uprv_memset(buf2, 0x4e, remain * 2);
str2.releaseBuffer(remain);
dest.append(str2);
Expand Down

0 comments on commit 18ba9f6

Please sign in to comment.