From 661cd1be03059c06e3fd10f1883e062f77a85072 Mon Sep 17 00:00:00 2001 From: Markus Scherer Date: Sat, 22 Sep 2001 00:56:23 +0000 Subject: [PATCH] ICU-1109 fix check for overlapping src/dest X-SVN-Rev: 5886 --- icu4c/source/common/unorm.cpp | 5 +++-- icu4c/source/common/ustring.c | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/icu4c/source/common/unorm.cpp b/icu4c/source/common/unorm.cpp index 4cbc317c731..d37f05e5b8c 100644 --- a/icu4c/source/common/unorm.cpp +++ b/icu4c/source/common/unorm.cpp @@ -2220,8 +2220,9 @@ unorm_normalize(const UChar *src, int32_t srcLength, } /* check for overlapping src and destination */ - if( (src>=dest && src<(dest+destCapacity)) || - (srcLength>0 && dest>=src && dest<(src+srcLength)) + if( dest!=NULL && + ((src>=dest && src<(dest+destCapacity)) || + (srcLength>0 && dest>=src && dest<(src+srcLength))) ) { *pErrorCode=U_ILLEGAL_ARGUMENT_ERROR; return 0; diff --git a/icu4c/source/common/ustring.c b/icu4c/source/common/ustring.c index 350e8c4991f..c65a01ba812 100644 --- a/icu4c/source/common/ustring.c +++ b/icu4c/source/common/ustring.c @@ -603,8 +603,9 @@ u_strCaseMap(UChar *dest, int32_t destCapacity, } /* check for overlapping source and destination */ - if( (src>=dest && src<(dest+destCapacity)) || - (dest>=src && dest<(src+srcLength)) + if( dest!=NULL && + ((src>=dest && src<(dest+destCapacity)) || + (dest>=src && dest<(src+srcLength))) ) { /* overlap: provide a temporary destination buffer and later copy the result */ if(destCapacity<=(sizeof(buffer)/U_SIZEOF_UCHAR)) {