ICU-861
Handled data strings of length 0 in the iterator constructor. X-SVN-Rev: 4810
This commit is contained in:
parent
6bc0d64b9d
commit
f96945e15a
@ -220,14 +220,21 @@ CollationElementIterator::CollationElementIterator(
|
||||
return;
|
||||
|
||||
int32_t length = sourceText.length();
|
||||
UChar *string = (UChar *)uprv_malloc(sizeof(UChar) * (length + 1));
|
||||
UChar *string = NULL;
|
||||
|
||||
if (length > 0) {
|
||||
string = (UChar *)uprv_malloc(sizeof(UChar) * length);
|
||||
/*
|
||||
Using this constructor will prevent buffer from being removed when
|
||||
string gets removed
|
||||
*/
|
||||
sourceText.extract(0, length, string);
|
||||
}
|
||||
else {
|
||||
string = (UChar *)uprv_malloc(sizeof(UChar));
|
||||
// null terminate it
|
||||
string[length] = 0;
|
||||
*string = 0;
|
||||
}
|
||||
|
||||
m_data_ = ucol_openElements(order->ucollator, string, length, &status);
|
||||
m_data_->isWritable = TRUE;
|
||||
|
Loading…
Reference in New Issue
Block a user