From 3de59e84c0ef0008689b418f2f7b2ac07b8141ca Mon Sep 17 00:00:00 2001 From: Markus Scherer Date: Tue, 7 Mar 2000 01:26:15 +0000 Subject: [PATCH] ICU-200 pointer wrap-around handling for os/400 X-SVN-Rev: 899 --- icu4c/source/common/ucnv.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/icu4c/source/common/ucnv.c b/icu4c/source/common/ucnv.c index 16ab84ce8c..7e36b340d8 100644 --- a/icu4c/source/common/ucnv.c +++ b/icu4c/source/common/ucnv.c @@ -643,8 +643,10 @@ int32_t ucnv_fromUChars (const UConverter * converter, mySource_limit = mySource + mySourceLength; myTarget_limit = target + targetSize; - if(myTarget_limit < target) /*if targetsize is such that the limit*/ - myTarget_limit = (char *)U_MAX_PTR; /* would wrap around, truncate it. */ + /* Pin the limit to U_MAX_PTR. NULL check is for AS/400. */ + if((myTarget_limit < target) || (myTarget_limit == NULL)) { + myTarget_limit = (char *)U_MAX_PTR; + } if (targetSize > 0) { @@ -752,9 +754,9 @@ int32_t ucnv_toUChars (const UConverter * converter, if (targetSize > 0) { myTarget_limit = target + targetSize - 1; - /*if targetsize is such that the limit*/ - if (myTarget_limit < target) { - /* would wrap around, truncate it. */ + + /* Pin the limit to U_MAX_PTR. NULL check is for AS/400. */ + if ((myTarget_limit == NULL) || (myTarget_limit < target)) { myTarget_limit = ((UChar*)U_MAX_PTR) - 1; }