ICU-8629 fix unsafe memcpy of UnicodeStrings.

X-SVN-Rev: 30254
This commit is contained in:
Andy Heninger 2011-06-29 23:25:35 +00:00
parent 5a0a5a7d87
commit fe56e19f40

View File

@ -234,10 +234,14 @@ void StringList::add(const UnicodeString *string, UErrorCode &status)
if (listSize >= listMax) {
int32_t newMax = listMax + STRING_LIST_BUFFER_SIZE;
UnicodeString *newStrings = new UnicodeString[newMax];
uprv_memcpy(newStrings, strings, listSize * sizeof(UnicodeString));
if (newStrings == NULL) {
status = U_MEMORY_ALLOCATION_ERROR;
return;
}
for (int32_t i=0; i<listSize; ++i) {
newStrings[i] = strings[i];
}
#ifdef INSTRUMENT_STRING_LIST
int32_t _h = listSize / STRING_LIST_BUFFER_SIZE;