8027775: Enhance ICU code.
authorprr
Mon, 16 Dec 2013 09:26:47 -0800
changeset 23908 fdbaab67db73
parent 23907 42205a8f63f3
child 23909 1ba74cd2a357
8027775: Enhance ICU code. Reviewed-by: srl, bae, mschoene
jdk/src/share/native/sun/font/layout/ContextualGlyphSubstProc2.cpp
jdk/src/share/native/sun/font/layout/ContextualSubstSubtables.cpp
jdk/src/share/native/sun/font/layout/LookupProcessor.cpp
jdk/src/share/native/sun/font/layout/MarkToBasePosnSubtables.cpp
jdk/src/share/native/sun/font/layout/OpenTypeUtilities.cpp
jdk/src/share/native/sun/font/layout/SegmentArrayProcessor.cpp
jdk/src/share/native/sun/font/layout/StateTableProcessor.cpp
--- a/jdk/src/share/native/sun/font/layout/ContextualGlyphSubstProc2.cpp	Wed Jan 22 09:42:51 2014 -0800
+++ b/jdk/src/share/native/sun/font/layout/ContextualGlyphSubstProc2.cpp	Mon Dec 16 09:26:47 2013 -0800
@@ -154,6 +154,7 @@
             TTGlyphID glyphCode = (TTGlyphID) LE_GET_GLYPH(gid);
             if ((glyphCode >= firstGlyph) && (glyphCode < lastGlyph)) {
               LEReferenceToArrayOf<LookupValue> valueArray(lookupTable8, success, &lookupTable8->valueArray[0], glyphCount);
+              if (LE_FAILURE(success)) { return newGlyph; }
               newGlyph = SWAPW(valueArray(glyphCode - firstGlyph, success));
             }
         }
--- a/jdk/src/share/native/sun/font/layout/ContextualSubstSubtables.cpp	Wed Jan 22 09:42:51 2014 -0800
+++ b/jdk/src/share/native/sun/font/layout/ContextualSubstSubtables.cpp	Mon Dec 16 09:26:47 2013 -0800
@@ -110,6 +110,8 @@
     LEErrorCode &success,
     le_bool backtrack)
 {
+    if (LE_FAILURE(success)) { return FALSE; }
+
     le_int32 direction = 1;
     le_int32 match = 0;
 
@@ -255,6 +257,7 @@
                 le_uint16 matchCount = SWAPW(subRuleTable->glyphCount) - 1;
                 le_uint16 substCount = SWAPW(subRuleTable->substCount);
                 LEReferenceToArrayOf<TTGlyphID> inputGlyphArray(base, success, subRuleTable->inputGlyphArray, matchCount+2);
+                if (LE_FAILURE(success)) { return 0; }
                 if (matchGlyphIDs(inputGlyphArray, matchCount, glyphIterator)) {
                   LEReferenceToArrayOf<SubstitutionLookupRecord>
                     substLookupRecordArray(base, success, (const SubstitutionLookupRecord *) &subRuleTable->inputGlyphArray[matchCount], substCount);
@@ -315,6 +318,7 @@
 
                 LEReferenceToArrayOf<le_uint16> classArray(base, success, subClassRuleTable->classArray, matchCount+1);
 
+                if (LE_FAILURE(success)) { return 0; }
                 if (matchGlyphClasses(classArray, matchCount, glyphIterator, classDefinitionTable, success)) {
                     LEReferenceToArrayOf<SubstitutionLookupRecord>
                       substLookupRecordArray(base, success, (const SubstitutionLookupRecord *) &subClassRuleTable->classArray[matchCount], substCount);
@@ -573,7 +577,7 @@
                 if (matchGlyphClasses(inputClassArray, inputGlyphCount, glyphIterator, inputClassDefinitionTable, success)) {
                     LEReferenceToArrayOf<SubstitutionLookupRecord>
                       substLookupRecordArray(base, success, (const SubstitutionLookupRecord *) lookaheadClassArray.getAlias(lookaheadGlyphCount + 1, success), substCount);
-
+                    if (LE_FAILURE(success)) { return 0; }
                     applySubstitutionLookups(lookupProcessor, substLookupRecordArray, substCount, glyphIterator, fontInstance, position, success);
 
                     return inputGlyphCount + 1;
@@ -601,9 +605,10 @@
     le_uint16 backtrkGlyphCount = SWAPW(backtrackGlyphCount);
     le_uint16 inputGlyphCount = (le_uint16) SWAPW(backtrackCoverageTableOffsetArray[backtrkGlyphCount]);
     LEReferenceToArrayOf<Offset>   inputCoverageTableOffsetArray(base, success, &backtrackCoverageTableOffsetArray[backtrkGlyphCount + 1], inputGlyphCount+2); // offset
+    if (LE_FAILURE(success)) { return 0; }
     const le_uint16 lookaheadGlyphCount = (le_uint16) SWAPW(inputCoverageTableOffsetArray[inputGlyphCount]);
 
-    if( LE_FAILURE(success) ) { return 0; }
+    if( LE_FAILURE(success)) { return 0; }
     LEReferenceToArrayOf<Offset>   lookaheadCoverageTableOffsetArray(base, success, inputCoverageTableOffsetArray.getAlias(inputGlyphCount + 1, success), lookaheadGlyphCount+2);
 
     if( LE_FAILURE(success) ) { return 0; }
--- a/jdk/src/share/native/sun/font/layout/LookupProcessor.cpp	Wed Jan 22 09:42:51 2014 -0800
+++ b/jdk/src/share/native/sun/font/layout/LookupProcessor.cpp	Mon Dec 16 09:26:47 2013 -0800
@@ -282,6 +282,7 @@
 
             for (le_uint16 feature = 0; feature < featureCount; feature += 1) {
               LEReferenceToArrayOf<le_uint16> featureIndexArray(langSysTable, success, langSysTable->featureIndexArray, featureCount);
+              if (LE_FAILURE(success)) { continue; }
               le_uint16 featureIndex = SWAPW(featureIndexArray.getObject(feature,success));
 
                 // don't add the required feature to the list more than once...
--- a/jdk/src/share/native/sun/font/layout/MarkToBasePosnSubtables.cpp	Wed Jan 22 09:42:51 2014 -0800
+++ b/jdk/src/share/native/sun/font/layout/MarkToBasePosnSubtables.cpp	Mon Dec 16 09:26:47 2013 -0800
@@ -67,6 +67,7 @@
 
     LEPoint markAnchor;
     LEReferenceTo<MarkArray> markArray(base, success,  (const MarkArray *) ((char *) this + SWAPW(markArrayOffset)));
+    if(LE_FAILURE(success)) return 0;
     le_int32 markClass = markArray->getMarkClass(markArray, markGlyph, markCoverage, fontInstance, markAnchor, success);
     le_uint16 mcCount = SWAPW(classCount);
 
--- a/jdk/src/share/native/sun/font/layout/OpenTypeUtilities.cpp	Wed Jan 22 09:42:51 2014 -0800
+++ b/jdk/src/share/native/sun/font/layout/OpenTypeUtilities.cpp	Mon Dec 16 09:26:47 2013 -0800
@@ -79,8 +79,8 @@
 
 Offset OpenTypeUtilities::getTagOffset(LETag tag, const LEReferenceToArrayOf<TagAndOffsetRecord> &records, LEErrorCode &success)
 {
+  if(LE_FAILURE(success)) return 0;
   const TagAndOffsetRecord *r0 = (const TagAndOffsetRecord*)records.getAlias();
-  if(LE_FAILURE(success)) return 0;
 
   le_uint32 recordCount = records.getCount();
   le_uint8 bit = highBit(recordCount);
--- a/jdk/src/share/native/sun/font/layout/SegmentArrayProcessor.cpp	Wed Jan 22 09:42:51 2014 -0800
+++ b/jdk/src/share/native/sun/font/layout/SegmentArrayProcessor.cpp	Mon Dec 16 09:26:47 2013 -0800
@@ -73,6 +73,7 @@
 
             if (offset != 0) {
               LEReferenceToArrayOf<TTGlyphID> glyphArray(subtableHeader, success, offset, LE_UNBOUNDED_ARRAY);
+              if (LE_FAILURE(success)) { continue; }
               TTGlyphID   newGlyph   = SWAPW(glyphArray(LE_GET_GLYPH(thisGlyph) - firstGlyph, success));
               glyphStorage[glyph] = LE_SET_GLYPH(thisGlyph, newGlyph);
             }
--- a/jdk/src/share/native/sun/font/layout/StateTableProcessor.cpp	Wed Jan 22 09:42:51 2014 -0800
+++ b/jdk/src/share/native/sun/font/layout/StateTableProcessor.cpp	Mon Dec 16 09:26:47 2013 -0800
@@ -97,6 +97,7 @@
 
         LEReferenceToArrayOf<EntryTableIndex> stateArray(stHeader, success, currentState, LE_UNBOUNDED_ARRAY);
         EntryTableIndex entryTableIndex = stateArray.getObject((le_uint8)classCode, success);
+        if (LE_FAILURE(success)) { break; }
         LE_STATE_PATIENCE_CURR(le_int32, currGlyph);
         currentState = processStateEntry(glyphStorage, currGlyph, entryTableIndex);
         LE_STATE_PATIENCE_INCR(currGlyph);