ICU-5161 Fix valgrind and Purify warnings about getTerminatedBuffer and uninitialized memory reads.

X-SVN-Rev: 19548
This commit is contained in:
George Rhoten 2006-04-14 21:43:21 +00:00
parent e88c000399
commit 4493abae62
2 changed files with 7 additions and 2 deletions

View File

@ -581,6 +581,10 @@ void TransliteratorIDParser::STVtoID(const UnicodeString& source,
if (variant.length() != 0) {
id.append(VARIANT_SEP).append(variant);
}
// NUL-terminate the ID string for getTerminatedBuffer.
// This prevents valgrind and Purify warnings.
id.append((UChar)0);
id.truncate(id.length()-1);
}
/**

View File

@ -1298,8 +1298,9 @@ inline int32_t Transliterator::getMaximumContextLength(void) const {
inline void Transliterator::setID(const UnicodeString& id) {
ID = id;
// NUL-terminate the ID string
ID.getTerminatedBuffer();
// NUL-terminate the ID string, which is a non-aliased copy.
ID.append((UChar)0);
ID.truncate(ID.length()-1);
}
inline Transliterator::Token Transliterator::integerToken(int32_t i) {