From a140572bbb94b6046a303c1b91cfc8a883a73183 Mon Sep 17 00:00:00 2001 From: Markus Scherer Date: Wed, 2 Jul 2003 17:23:15 +0000 Subject: [PATCH] ICU-2329 always NUL-terminate the ID string for ID enumeration in C APIs X-SVN-Rev: 12583 --- icu4c/source/i18n/translit.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/icu4c/source/i18n/translit.cpp b/icu4c/source/i18n/translit.cpp index f5e8a56e722..a1f4813083a 100644 --- a/icu4c/source/i18n/translit.cpp +++ b/icu4c/source/i18n/translit.cpp @@ -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;