X-Git-Url: https://git.saurik.com/apple/icu.git/blobdiff_plain/73c04bcfe1096173b00431f0cdc742894b15eef0..f3c0d7a59d99c2a94c6b8822291f0e42be3773c9:/icuSources/i18n/unesctrn.cpp diff --git a/icuSources/i18n/unesctrn.cpp b/icuSources/i18n/unesctrn.cpp index 45ced8b1..86c55d13 100644 --- a/icuSources/i18n/unesctrn.cpp +++ b/icuSources/i18n/unesctrn.cpp @@ -1,6 +1,8 @@ +// © 2016 and later: Unicode, Inc. and others. +// License & terms of use: http://www.unicode.org/copyright.html /* ********************************************************************** - * Copyright (c) 2001-2004, International Business Machines + * Copyright (c) 2001-2011, International Business Machines * Corporation and others. All Rights Reserved. ********************************************************************** * Date Name Description @@ -13,6 +15,7 @@ #if !UCONFIG_NO_TRANSLITERATION #include "unicode/uchar.h" +#include "unicode/utf16.h" #include "unesctrn.h" #include "util.h" @@ -82,7 +85,10 @@ static UChar* copySpec(const UChar* spec) { } ++len; UChar *result = (UChar *)uprv_malloc(len*sizeof(UChar)); - uprv_memcpy(result, spec, len*sizeof(result[0])); + // Check for memory allocation error. + if (result != NULL) { + uprv_memcpy(result, spec, (size_t)len*sizeof(result[0])); + } return result; } @@ -226,7 +232,7 @@ void UnescapeTransliterator::handleTransliterate(Replaceable& text, UTransPositi if (digit < 0) { break; } - s += UTF_CHAR_LENGTH(ch); + s += U16_LENGTH(ch); u = (u * radix) + digit; if (++digitCount == maxDigits) { break; @@ -270,7 +276,7 @@ void UnescapeTransliterator::handleTransliterate(Replaceable& text, UTransPositi } if (start < limit) { - start += UTF_CHAR_LENGTH(text.char32At(start)); + start += U16_LENGTH(text.char32At(start)); } }