diff --git a/icu4c/source/common/loadednormalizer2impl.cpp b/icu4c/source/common/loadednormalizer2impl.cpp index bd37b95eadc..0a4bef4adf7 100644 --- a/icu4c/source/common/loadednormalizer2impl.cpp +++ b/icu4c/source/common/loadednormalizer2impl.cpp @@ -84,7 +84,7 @@ LoadedNormalizer2Impl::load(const char *packageName, const char *name, UErrorCod const uint8_t *inBytes=(const uint8_t *)udata_getMemory(memory); const int32_t *inIndexes=(const int32_t *)inBytes; int32_t indexesLength=inIndexes[IX_NORM_TRIE_OFFSET]/4; - if(indexesLength<=IX_MIN_MAYBE_YES) { + if(indexesLength<=IX_MIN_YES_NO_MAPPINGS_ONLY) { errorCode=U_INVALID_FORMAT_ERROR; // Not enough indexes. return; } diff --git a/icu4c/source/common/norm2allmodes.h b/icu4c/source/common/norm2allmodes.h index 91c8634a1f6..31aaf45d667 100644 --- a/icu4c/source/common/norm2allmodes.h +++ b/icu4c/source/common/norm2allmodes.h @@ -5,7 +5,7 @@ * Copyright (C) 2014, International Business Machines * Corporation and others. All Rights Reserved. ******************************************************************************* -* loadednormalizer2impl.h +* norm2allmodes.h * * created on: 2014sep07 * created by: Markus W. Scherer diff --git a/icu4c/source/common/normalizer2impl.cpp b/icu4c/source/common/normalizer2impl.cpp index 6a6124f4b75..757a0c3f6bd 100644 --- a/icu4c/source/common/normalizer2impl.cpp +++ b/icu4c/source/common/normalizer2impl.cpp @@ -2645,12 +2645,13 @@ unorm2_swap(const UDataSwapper *ds, /* check data format and format version */ pInfo=(const UDataInfo *)((const char *)inData+4); + uint8_t formatVersion0=pInfo->formatVersion[0]; if(!( pInfo->dataFormat[0]==0x4e && /* dataFormat="Nrm2" */ pInfo->dataFormat[1]==0x72 && pInfo->dataFormat[2]==0x6d && pInfo->dataFormat[3]==0x32 && - (pInfo->formatVersion[0]==1 || pInfo->formatVersion[0]==2) + (formatVersion0==1 || formatVersion0==2) )) { udata_printError(ds, "unorm2_swap(): data format %02x.%02x.%02x.%02x (format version %02x) is not recognized as Normalizer2 data\n", pInfo->dataFormat[0], pInfo->dataFormat[1], @@ -2664,10 +2665,16 @@ unorm2_swap(const UDataSwapper *ds, outBytes=(uint8_t *)outData+headerSize; inIndexes=(const int32_t *)inBytes; + int32_t minIndexesLength; + if(formatVersion0==1) { + minIndexesLength=Normalizer2Impl::IX_MIN_MAYBE_YES+1; + } else { + minIndexesLength=Normalizer2Impl::IX_MIN_YES_NO_MAPPINGS_ONLY+1; + } if(length>=0) { length-=headerSize; - if(length<(int32_t)sizeof(indexes)) { + if(length