ICU-2329 always NUL-terminate the ID string for ID enumeration in C APIs

X-SVN-Rev: 12583
This commit is contained in:
Markus Scherer 2003-07-02 17:23:15 +00:00
parent 5b46dcd196
commit a140572bbb

View file

@ -129,7 +129,11 @@ inline UBool positionIsValid(UTransPosition& index, int32_t len) {
Transliterator::Transliterator(const UnicodeString& theID,
UnicodeFilter* adoptedFilter) :
UObject(), ID(theID), filter(adoptedFilter),
maximumContextLength(0) {}
maximumContextLength(0) {
// NUL-terminate the ID string
ID.getTerminatedBuffer();
}
/**
* Destructor.
@ -144,6 +148,10 @@ Transliterator::~Transliterator() {
Transliterator::Transliterator(const Transliterator& other) :
UObject(other), ID(other.ID), filter(0),
maximumContextLength(other.maximumContextLength) {
// NUL-terminate the ID string
ID.getTerminatedBuffer();
if (other.filter != 0) {
// We own the filter, so we must have our own copy
filter = (UnicodeFilter*) other.filter->clone();
@ -155,6 +163,9 @@ Transliterator::Transliterator(const Transliterator& other) :
*/
Transliterator& Transliterator::operator=(const Transliterator& other) {
ID = other.ID;
// NUL-terminate the ID string
ID.getTerminatedBuffer();
maximumContextLength = other.maximumContextLength;
adoptFilter((other.filter == 0) ? 0 : (UnicodeFilter*) other.filter->clone());
return *this;