From 560b782d424e27cfac7044f6262e3ebf50bd3a79 Mon Sep 17 00:00:00 2001 From: Markus Scherer Date: Tue, 13 Nov 2001 19:27:56 +0000 Subject: [PATCH] ICU-785 add length check when getting surrogate pairs X-SVN-Rev: 6829 --- icu4c/source/common/ustring.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/icu4c/source/common/ustring.c b/icu4c/source/common/ustring.c index 5e3442d372..0acf68527d 100644 --- a/icu4c/source/common/ustring.c +++ b/icu4c/source/common/ustring.c @@ -830,7 +830,7 @@ u_internalStrcasecmp(const UChar *s1, int32_t length1, if(pos1>=len1) { if(length1>0) { c=*s1++; - if(UTF_IS_FIRST_SURROGATE(c) && UTF_IS_SECOND_SURROGATE(uc=*s1)) { + if(UTF_IS_FIRST_SURROGATE(c) && length1>1 && UTF_IS_SECOND_SURROGATE(uc=*s1)) { c=UTF16_GET_PAIR_VALUE(c, uc); ++s1; length1-=2; @@ -848,7 +848,7 @@ u_internalStrcasecmp(const UChar *s1, int32_t length1, if(pos2>=len2) { if(length2>0) { c=*s2++; - if(UTF_IS_FIRST_SURROGATE(c) && UTF_IS_SECOND_SURROGATE(uc=*s2)) { + if(UTF_IS_FIRST_SURROGATE(c) && length2>1 && UTF_IS_SECOND_SURROGATE(uc=*s2)) { c=UTF16_GET_PAIR_VALUE(c, uc); ++s2; length2-=2;