提交 2ed510da 编写于 作者: P prr

8132042: Preserve layout presentation

Reviewed-by: mschoene, srl, serb
上级 b8b26802
...@@ -76,14 +76,14 @@ ByteOffset IndicRearrangementProcessor::processStateEntry(LEGlyphStorage &glyphS ...@@ -76,14 +76,14 @@ ByteOffset IndicRearrangementProcessor::processStateEntry(LEGlyphStorage &glyphS
} }
if (flags & irfMarkFirst) { if (flags & irfMarkFirst) {
firstGlyph = currGlyph; firstGlyph = (le_uint32)currGlyph;
} }
if (flags & irfMarkLast) { if (flags & irfMarkLast) {
lastGlyph = currGlyph; lastGlyph = (le_uint32)currGlyph;
} }
doRearrangementAction(glyphStorage, (IndicRearrangementVerb) (flags & irfVerbMask)); doRearrangementAction(glyphStorage, (IndicRearrangementVerb) (flags & irfVerbMask), success);
if (!(flags & irfDontAdvance)) { if (!(flags & irfDontAdvance)) {
// XXX: Should handle reverse too... // XXX: Should handle reverse too...
...@@ -97,18 +97,29 @@ void IndicRearrangementProcessor::endStateTable() ...@@ -97,18 +97,29 @@ void IndicRearrangementProcessor::endStateTable()
{ {
} }
void IndicRearrangementProcessor::doRearrangementAction(LEGlyphStorage &glyphStorage, IndicRearrangementVerb verb) const void IndicRearrangementProcessor::doRearrangementAction(LEGlyphStorage &glyphStorage, IndicRearrangementVerb verb, LEErrorCode &success) const
{ {
LEGlyphID a, b, c, d; LEGlyphID a, b, c, d;
le_int32 ia, ib, ic, id, ix, x; le_int32 ia, ib, ic, id, ix, x;
LEErrorCode success = LE_NO_ERROR;
if (LE_FAILURE(success)) return;
if (verb == irvNoAction) {
return;
}
if (firstGlyph > lastGlyph) {
success = LE_INDEX_OUT_OF_BOUNDS_ERROR;
return;
}
switch(verb) switch(verb)
{ {
case irvNoAction:
break;
case irvxA: case irvxA:
if (firstGlyph == lastGlyph) break;
if (firstGlyph + 1 < firstGlyph) {
success = LE_INDEX_OUT_OF_BOUNDS_ERROR;
break;
}
a = glyphStorage[firstGlyph]; a = glyphStorage[firstGlyph];
ia = glyphStorage.getCharIndex(firstGlyph, success); ia = glyphStorage.getCharIndex(firstGlyph, success);
x = firstGlyph + 1; x = firstGlyph + 1;
...@@ -125,6 +136,11 @@ void IndicRearrangementProcessor::doRearrangementAction(LEGlyphStorage &glyphSto ...@@ -125,6 +136,11 @@ void IndicRearrangementProcessor::doRearrangementAction(LEGlyphStorage &glyphSto
break; break;
case irvDx: case irvDx:
if (firstGlyph == lastGlyph) break;
if (lastGlyph - 1 > lastGlyph) {
success = LE_INDEX_OUT_OF_BOUNDS_ERROR;
break;
}
d = glyphStorage[lastGlyph]; d = glyphStorage[lastGlyph];
id = glyphStorage.getCharIndex(lastGlyph, success); id = glyphStorage.getCharIndex(lastGlyph, success);
x = lastGlyph - 1; x = lastGlyph - 1;
...@@ -153,6 +169,11 @@ void IndicRearrangementProcessor::doRearrangementAction(LEGlyphStorage &glyphSto ...@@ -153,6 +169,11 @@ void IndicRearrangementProcessor::doRearrangementAction(LEGlyphStorage &glyphSto
break; break;
case irvxAB: case irvxAB:
if ((firstGlyph + 2 < firstGlyph) ||
(lastGlyph - firstGlyph < 1)) { // difference == 1 is a no-op, < 1 is an error.
success = LE_INDEX_OUT_OF_BOUNDS_ERROR;
break;
}
a = glyphStorage[firstGlyph]; a = glyphStorage[firstGlyph];
b = glyphStorage[firstGlyph + 1]; b = glyphStorage[firstGlyph + 1];
ia = glyphStorage.getCharIndex(firstGlyph, success); ia = glyphStorage.getCharIndex(firstGlyph, success);
...@@ -174,6 +195,11 @@ void IndicRearrangementProcessor::doRearrangementAction(LEGlyphStorage &glyphSto ...@@ -174,6 +195,11 @@ void IndicRearrangementProcessor::doRearrangementAction(LEGlyphStorage &glyphSto
break; break;
case irvxBA: case irvxBA:
if ((firstGlyph + 2 < firstGlyph) ||
(lastGlyph - firstGlyph < 1)) {
success = LE_INDEX_OUT_OF_BOUNDS_ERROR;
break;
}
a = glyphStorage[firstGlyph]; a = glyphStorage[firstGlyph];
b = glyphStorage[firstGlyph + 1]; b = glyphStorage[firstGlyph + 1];
ia = glyphStorage.getCharIndex(firstGlyph, success); ia = glyphStorage.getCharIndex(firstGlyph, success);
...@@ -195,6 +221,11 @@ void IndicRearrangementProcessor::doRearrangementAction(LEGlyphStorage &glyphSto ...@@ -195,6 +221,11 @@ void IndicRearrangementProcessor::doRearrangementAction(LEGlyphStorage &glyphSto
break; break;
case irvCDx: case irvCDx:
if ((lastGlyph - 2 > lastGlyph) ||
(lastGlyph - firstGlyph < 1)) {
success = LE_INDEX_OUT_OF_BOUNDS_ERROR;
break;
}
c = glyphStorage[lastGlyph - 1]; c = glyphStorage[lastGlyph - 1];
d = glyphStorage[lastGlyph]; d = glyphStorage[lastGlyph];
ic = glyphStorage.getCharIndex(lastGlyph - 1, success); ic = glyphStorage.getCharIndex(lastGlyph - 1, success);
...@@ -216,6 +247,11 @@ void IndicRearrangementProcessor::doRearrangementAction(LEGlyphStorage &glyphSto ...@@ -216,6 +247,11 @@ void IndicRearrangementProcessor::doRearrangementAction(LEGlyphStorage &glyphSto
break; break;
case irvDCx: case irvDCx:
if ((lastGlyph - 2 > lastGlyph) ||
(lastGlyph - firstGlyph < 1)) {
success = LE_INDEX_OUT_OF_BOUNDS_ERROR;
break;
}
c = glyphStorage[lastGlyph - 1]; c = glyphStorage[lastGlyph - 1];
d = glyphStorage[lastGlyph]; d = glyphStorage[lastGlyph];
ic = glyphStorage.getCharIndex(lastGlyph - 1, success); ic = glyphStorage.getCharIndex(lastGlyph - 1, success);
...@@ -237,6 +273,11 @@ void IndicRearrangementProcessor::doRearrangementAction(LEGlyphStorage &glyphSto ...@@ -237,6 +273,11 @@ void IndicRearrangementProcessor::doRearrangementAction(LEGlyphStorage &glyphSto
break; break;
case irvCDxA: case irvCDxA:
if ((lastGlyph - 2 > lastGlyph) ||
(lastGlyph - firstGlyph < 2)) {
success = LE_INDEX_OUT_OF_BOUNDS_ERROR;
break;
}
a = glyphStorage[firstGlyph]; a = glyphStorage[firstGlyph];
c = glyphStorage[lastGlyph - 1]; c = glyphStorage[lastGlyph - 1];
d = glyphStorage[lastGlyph]; d = glyphStorage[lastGlyph];
...@@ -262,6 +303,11 @@ void IndicRearrangementProcessor::doRearrangementAction(LEGlyphStorage &glyphSto ...@@ -262,6 +303,11 @@ void IndicRearrangementProcessor::doRearrangementAction(LEGlyphStorage &glyphSto
break; break;
case irvDCxA: case irvDCxA:
if ((lastGlyph - 2 > lastGlyph) ||
(lastGlyph - firstGlyph < 2)) {
success = LE_INDEX_OUT_OF_BOUNDS_ERROR;
break;
}
a = glyphStorage[firstGlyph]; a = glyphStorage[firstGlyph];
c = glyphStorage[lastGlyph - 1]; c = glyphStorage[lastGlyph - 1];
d = glyphStorage[lastGlyph]; d = glyphStorage[lastGlyph];
...@@ -287,6 +333,11 @@ void IndicRearrangementProcessor::doRearrangementAction(LEGlyphStorage &glyphSto ...@@ -287,6 +333,11 @@ void IndicRearrangementProcessor::doRearrangementAction(LEGlyphStorage &glyphSto
break; break;
case irvDxAB: case irvDxAB:
if ((firstGlyph + 2 < firstGlyph) ||
(lastGlyph - firstGlyph < 2)) {
success = LE_INDEX_OUT_OF_BOUNDS_ERROR;
break;
}
a = glyphStorage[firstGlyph]; a = glyphStorage[firstGlyph];
b = glyphStorage[firstGlyph + 1]; b = glyphStorage[firstGlyph + 1];
d = glyphStorage[lastGlyph]; d = glyphStorage[lastGlyph];
...@@ -312,6 +363,11 @@ void IndicRearrangementProcessor::doRearrangementAction(LEGlyphStorage &glyphSto ...@@ -312,6 +363,11 @@ void IndicRearrangementProcessor::doRearrangementAction(LEGlyphStorage &glyphSto
break; break;
case irvDxBA: case irvDxBA:
if ((firstGlyph + 2 < firstGlyph) ||
(lastGlyph - firstGlyph < 2)) {
success = LE_INDEX_OUT_OF_BOUNDS_ERROR;
break;
}
a = glyphStorage[firstGlyph]; a = glyphStorage[firstGlyph];
b = glyphStorage[firstGlyph + 1]; b = glyphStorage[firstGlyph + 1];
d = glyphStorage[lastGlyph]; d = glyphStorage[lastGlyph];
...@@ -337,6 +393,10 @@ void IndicRearrangementProcessor::doRearrangementAction(LEGlyphStorage &glyphSto ...@@ -337,6 +393,10 @@ void IndicRearrangementProcessor::doRearrangementAction(LEGlyphStorage &glyphSto
break; break;
case irvCDxAB: case irvCDxAB:
if (lastGlyph - firstGlyph < 3) {
success = LE_INDEX_OUT_OF_BOUNDS_ERROR;
break;
}
a = glyphStorage[firstGlyph]; a = glyphStorage[firstGlyph];
b = glyphStorage[firstGlyph + 1]; b = glyphStorage[firstGlyph + 1];
...@@ -359,6 +419,10 @@ void IndicRearrangementProcessor::doRearrangementAction(LEGlyphStorage &glyphSto ...@@ -359,6 +419,10 @@ void IndicRearrangementProcessor::doRearrangementAction(LEGlyphStorage &glyphSto
break; break;
case irvCDxBA: case irvCDxBA:
if (lastGlyph - firstGlyph < 3) {
success = LE_INDEX_OUT_OF_BOUNDS_ERROR;
break;
}
a = glyphStorage[firstGlyph]; a = glyphStorage[firstGlyph];
b = glyphStorage[firstGlyph + 1]; b = glyphStorage[firstGlyph + 1];
...@@ -381,6 +445,10 @@ void IndicRearrangementProcessor::doRearrangementAction(LEGlyphStorage &glyphSto ...@@ -381,6 +445,10 @@ void IndicRearrangementProcessor::doRearrangementAction(LEGlyphStorage &glyphSto
break; break;
case irvDCxAB: case irvDCxAB:
if (lastGlyph - firstGlyph < 3) {
success = LE_INDEX_OUT_OF_BOUNDS_ERROR;
break;
}
a = glyphStorage[firstGlyph]; a = glyphStorage[firstGlyph];
b = glyphStorage[firstGlyph + 1]; b = glyphStorage[firstGlyph + 1];
...@@ -403,6 +471,10 @@ void IndicRearrangementProcessor::doRearrangementAction(LEGlyphStorage &glyphSto ...@@ -403,6 +471,10 @@ void IndicRearrangementProcessor::doRearrangementAction(LEGlyphStorage &glyphSto
break; break;
case irvDCxBA: case irvDCxBA:
if (lastGlyph - firstGlyph < 3) {
success = LE_INDEX_OUT_OF_BOUNDS_ERROR;
break;
}
a = glyphStorage[firstGlyph]; a = glyphStorage[firstGlyph];
b = glyphStorage[firstGlyph + 1]; b = glyphStorage[firstGlyph + 1];
......
...@@ -56,7 +56,7 @@ public: ...@@ -56,7 +56,7 @@ public:
virtual void endStateTable(); virtual void endStateTable();
void doRearrangementAction(LEGlyphStorage &glyphStorage, IndicRearrangementVerb verb) const; void doRearrangementAction(LEGlyphStorage &glyphStorage, IndicRearrangementVerb verb, LEErrorCode &success) const;
IndicRearrangementProcessor(const LEReferenceTo<MorphSubtableHeader> &morphSubtableHeader, LEErrorCode &success); IndicRearrangementProcessor(const LEReferenceTo<MorphSubtableHeader> &morphSubtableHeader, LEErrorCode &success);
virtual ~IndicRearrangementProcessor(); virtual ~IndicRearrangementProcessor();
...@@ -76,8 +76,8 @@ public: ...@@ -76,8 +76,8 @@ public:
static UClassID getStaticClassID(); static UClassID getStaticClassID();
protected: protected:
le_int32 firstGlyph; le_uint32 firstGlyph;
le_int32 lastGlyph; le_uint32 lastGlyph;
LEReferenceTo<IndicRearrangementSubtableHeader> indicRearrangementSubtableHeader; LEReferenceTo<IndicRearrangementSubtableHeader> indicRearrangementSubtableHeader;
LEReferenceToArrayOf<IndicRearrangementStateEntry> entryTable; LEReferenceToArrayOf<IndicRearrangementStateEntry> entryTable;
......
...@@ -74,14 +74,14 @@ le_uint16 IndicRearrangementProcessor2::processStateEntry(LEGlyphStorage &glyphS ...@@ -74,14 +74,14 @@ le_uint16 IndicRearrangementProcessor2::processStateEntry(LEGlyphStorage &glyphS
} }
if (flags & irfMarkFirst) { if (flags & irfMarkFirst) {
firstGlyph = currGlyph; firstGlyph = (le_uint32)currGlyph;
} }
if (flags & irfMarkLast) { if (flags & irfMarkLast) {
lastGlyph = currGlyph; lastGlyph = (le_uint32)currGlyph;
} }
doRearrangementAction(glyphStorage, (IndicRearrangementVerb) (flags & irfVerbMask)); doRearrangementAction(glyphStorage, (IndicRearrangementVerb) (flags & irfVerbMask), success);
if (!(flags & irfDontAdvance)) { if (!(flags & irfDontAdvance)) {
currGlyph += dir; currGlyph += dir;
...@@ -94,18 +94,29 @@ void IndicRearrangementProcessor2::endStateTable() ...@@ -94,18 +94,29 @@ void IndicRearrangementProcessor2::endStateTable()
{ {
} }
void IndicRearrangementProcessor2::doRearrangementAction(LEGlyphStorage &glyphStorage, IndicRearrangementVerb verb) const void IndicRearrangementProcessor2::doRearrangementAction(LEGlyphStorage &glyphStorage, IndicRearrangementVerb verb, LEErrorCode &success) const
{ {
LEGlyphID a, b, c, d; LEGlyphID a, b, c, d;
le_int32 ia, ib, ic, id, ix, x; le_int32 ia, ib, ic, id, ix, x;
LEErrorCode success = LE_NO_ERROR;
if (LE_FAILURE(success)) return;
if (verb == irvNoAction) {
return;
}
if (firstGlyph > lastGlyph) {
success = LE_INDEX_OUT_OF_BOUNDS_ERROR;
return;
}
switch(verb) switch(verb)
{ {
case irvNoAction:
break;
case irvxA: case irvxA:
if (firstGlyph == lastGlyph) break;
if (firstGlyph + 1 < firstGlyph) {
success = LE_INDEX_OUT_OF_BOUNDS_ERROR;
break;
}
a = glyphStorage[firstGlyph]; a = glyphStorage[firstGlyph];
ia = glyphStorage.getCharIndex(firstGlyph, success); ia = glyphStorage.getCharIndex(firstGlyph, success);
x = firstGlyph + 1; x = firstGlyph + 1;
...@@ -122,6 +133,11 @@ void IndicRearrangementProcessor2::doRearrangementAction(LEGlyphStorage &glyphSt ...@@ -122,6 +133,11 @@ void IndicRearrangementProcessor2::doRearrangementAction(LEGlyphStorage &glyphSt
break; break;
case irvDx: case irvDx:
if (firstGlyph == lastGlyph) break;
if (lastGlyph - 1 > lastGlyph) {
success = LE_INDEX_OUT_OF_BOUNDS_ERROR;
break;
}
d = glyphStorage[lastGlyph]; d = glyphStorage[lastGlyph];
id = glyphStorage.getCharIndex(lastGlyph, success); id = glyphStorage.getCharIndex(lastGlyph, success);
x = lastGlyph - 1; x = lastGlyph - 1;
...@@ -150,6 +166,11 @@ void IndicRearrangementProcessor2::doRearrangementAction(LEGlyphStorage &glyphSt ...@@ -150,6 +166,11 @@ void IndicRearrangementProcessor2::doRearrangementAction(LEGlyphStorage &glyphSt
break; break;
case irvxAB: case irvxAB:
if ((firstGlyph + 2 < firstGlyph) ||
(lastGlyph - firstGlyph < 1)) { // difference == 1 is a no-op, < 1 is an error.
success = LE_INDEX_OUT_OF_BOUNDS_ERROR;
break;
}
a = glyphStorage[firstGlyph]; a = glyphStorage[firstGlyph];
b = glyphStorage[firstGlyph + 1]; b = glyphStorage[firstGlyph + 1];
ia = glyphStorage.getCharIndex(firstGlyph, success); ia = glyphStorage.getCharIndex(firstGlyph, success);
...@@ -171,6 +192,11 @@ void IndicRearrangementProcessor2::doRearrangementAction(LEGlyphStorage &glyphSt ...@@ -171,6 +192,11 @@ void IndicRearrangementProcessor2::doRearrangementAction(LEGlyphStorage &glyphSt
break; break;
case irvxBA: case irvxBA:
if ((firstGlyph + 2 < firstGlyph) ||
(lastGlyph - firstGlyph < 1)) {
success = LE_INDEX_OUT_OF_BOUNDS_ERROR;
break;
}
a = glyphStorage[firstGlyph]; a = glyphStorage[firstGlyph];
b = glyphStorage[firstGlyph + 1]; b = glyphStorage[firstGlyph + 1];
ia = glyphStorage.getCharIndex(firstGlyph, success); ia = glyphStorage.getCharIndex(firstGlyph, success);
...@@ -192,6 +218,11 @@ void IndicRearrangementProcessor2::doRearrangementAction(LEGlyphStorage &glyphSt ...@@ -192,6 +218,11 @@ void IndicRearrangementProcessor2::doRearrangementAction(LEGlyphStorage &glyphSt
break; break;
case irvCDx: case irvCDx:
if ((lastGlyph - 2 > lastGlyph) ||
(lastGlyph - firstGlyph < 1)) {
success = LE_INDEX_OUT_OF_BOUNDS_ERROR;
break;
}
c = glyphStorage[lastGlyph - 1]; c = glyphStorage[lastGlyph - 1];
d = glyphStorage[lastGlyph]; d = glyphStorage[lastGlyph];
ic = glyphStorage.getCharIndex(lastGlyph - 1, success); ic = glyphStorage.getCharIndex(lastGlyph - 1, success);
...@@ -213,6 +244,11 @@ void IndicRearrangementProcessor2::doRearrangementAction(LEGlyphStorage &glyphSt ...@@ -213,6 +244,11 @@ void IndicRearrangementProcessor2::doRearrangementAction(LEGlyphStorage &glyphSt
break; break;
case irvDCx: case irvDCx:
if ((lastGlyph - 2 > lastGlyph) ||
(lastGlyph - firstGlyph < 1)) {
success = LE_INDEX_OUT_OF_BOUNDS_ERROR;
break;
}
c = glyphStorage[lastGlyph - 1]; c = glyphStorage[lastGlyph - 1];
d = glyphStorage[lastGlyph]; d = glyphStorage[lastGlyph];
ic = glyphStorage.getCharIndex(lastGlyph - 1, success); ic = glyphStorage.getCharIndex(lastGlyph - 1, success);
...@@ -234,6 +270,11 @@ void IndicRearrangementProcessor2::doRearrangementAction(LEGlyphStorage &glyphSt ...@@ -234,6 +270,11 @@ void IndicRearrangementProcessor2::doRearrangementAction(LEGlyphStorage &glyphSt
break; break;
case irvCDxA: case irvCDxA:
if ((lastGlyph - 2 > lastGlyph) ||
(lastGlyph - firstGlyph < 2)) {
success = LE_INDEX_OUT_OF_BOUNDS_ERROR;
break;
}
a = glyphStorage[firstGlyph]; a = glyphStorage[firstGlyph];
c = glyphStorage[lastGlyph - 1]; c = glyphStorage[lastGlyph - 1];
d = glyphStorage[lastGlyph]; d = glyphStorage[lastGlyph];
...@@ -259,6 +300,11 @@ void IndicRearrangementProcessor2::doRearrangementAction(LEGlyphStorage &glyphSt ...@@ -259,6 +300,11 @@ void IndicRearrangementProcessor2::doRearrangementAction(LEGlyphStorage &glyphSt
break; break;
case irvDCxA: case irvDCxA:
if ((lastGlyph - 2 > lastGlyph) ||
(lastGlyph - firstGlyph < 2)) {
success = LE_INDEX_OUT_OF_BOUNDS_ERROR;
break;
}
a = glyphStorage[firstGlyph]; a = glyphStorage[firstGlyph];
c = glyphStorage[lastGlyph - 1]; c = glyphStorage[lastGlyph - 1];
d = glyphStorage[lastGlyph]; d = glyphStorage[lastGlyph];
...@@ -284,6 +330,11 @@ void IndicRearrangementProcessor2::doRearrangementAction(LEGlyphStorage &glyphSt ...@@ -284,6 +330,11 @@ void IndicRearrangementProcessor2::doRearrangementAction(LEGlyphStorage &glyphSt
break; break;
case irvDxAB: case irvDxAB:
if ((firstGlyph + 2 < firstGlyph) ||
(lastGlyph - firstGlyph < 2)) {
success = LE_INDEX_OUT_OF_BOUNDS_ERROR;
break;
}
a = glyphStorage[firstGlyph]; a = glyphStorage[firstGlyph];
b = glyphStorage[firstGlyph + 1]; b = glyphStorage[firstGlyph + 1];
d = glyphStorage[lastGlyph]; d = glyphStorage[lastGlyph];
...@@ -309,6 +360,11 @@ void IndicRearrangementProcessor2::doRearrangementAction(LEGlyphStorage &glyphSt ...@@ -309,6 +360,11 @@ void IndicRearrangementProcessor2::doRearrangementAction(LEGlyphStorage &glyphSt
break; break;
case irvDxBA: case irvDxBA:
if ((firstGlyph + 2 < firstGlyph) ||
(lastGlyph - firstGlyph < 2)) {
success = LE_INDEX_OUT_OF_BOUNDS_ERROR;
break;
}
a = glyphStorage[firstGlyph]; a = glyphStorage[firstGlyph];
b = glyphStorage[firstGlyph + 1]; b = glyphStorage[firstGlyph + 1];
d = glyphStorage[lastGlyph]; d = glyphStorage[lastGlyph];
...@@ -334,6 +390,10 @@ void IndicRearrangementProcessor2::doRearrangementAction(LEGlyphStorage &glyphSt ...@@ -334,6 +390,10 @@ void IndicRearrangementProcessor2::doRearrangementAction(LEGlyphStorage &glyphSt
break; break;
case irvCDxAB: case irvCDxAB:
if (lastGlyph - firstGlyph < 3) {
success = LE_INDEX_OUT_OF_BOUNDS_ERROR;
break;
}
a = glyphStorage[firstGlyph]; a = glyphStorage[firstGlyph];
b = glyphStorage[firstGlyph + 1]; b = glyphStorage[firstGlyph + 1];
...@@ -356,6 +416,10 @@ void IndicRearrangementProcessor2::doRearrangementAction(LEGlyphStorage &glyphSt ...@@ -356,6 +416,10 @@ void IndicRearrangementProcessor2::doRearrangementAction(LEGlyphStorage &glyphSt
break; break;
case irvCDxBA: case irvCDxBA:
if (lastGlyph - firstGlyph < 3) {
success = LE_INDEX_OUT_OF_BOUNDS_ERROR;
break;
}
a = glyphStorage[firstGlyph]; a = glyphStorage[firstGlyph];
b = glyphStorage[firstGlyph + 1]; b = glyphStorage[firstGlyph + 1];
...@@ -378,6 +442,10 @@ void IndicRearrangementProcessor2::doRearrangementAction(LEGlyphStorage &glyphSt ...@@ -378,6 +442,10 @@ void IndicRearrangementProcessor2::doRearrangementAction(LEGlyphStorage &glyphSt
break; break;
case irvDCxAB: case irvDCxAB:
if (lastGlyph - firstGlyph < 3) {
success = LE_INDEX_OUT_OF_BOUNDS_ERROR;
break;
}
a = glyphStorage[firstGlyph]; a = glyphStorage[firstGlyph];
b = glyphStorage[firstGlyph + 1]; b = glyphStorage[firstGlyph + 1];
...@@ -400,6 +468,10 @@ void IndicRearrangementProcessor2::doRearrangementAction(LEGlyphStorage &glyphSt ...@@ -400,6 +468,10 @@ void IndicRearrangementProcessor2::doRearrangementAction(LEGlyphStorage &glyphSt
break; break;
case irvDCxBA: case irvDCxBA:
if (lastGlyph - firstGlyph < 3) {
success = LE_INDEX_OUT_OF_BOUNDS_ERROR;
break;
}
a = glyphStorage[firstGlyph]; a = glyphStorage[firstGlyph];
b = glyphStorage[firstGlyph + 1]; b = glyphStorage[firstGlyph + 1];
......
...@@ -56,7 +56,7 @@ public: ...@@ -56,7 +56,7 @@ public:
virtual void endStateTable(); virtual void endStateTable();
void doRearrangementAction(LEGlyphStorage &glyphStorage, IndicRearrangementVerb verb) const; void doRearrangementAction(LEGlyphStorage &glyphStorage, IndicRearrangementVerb verb, LEErrorCode &success) const;
IndicRearrangementProcessor2(const LEReferenceTo<MorphSubtableHeader2> &morphSubtableHeader, LEErrorCode &success); IndicRearrangementProcessor2(const LEReferenceTo<MorphSubtableHeader2> &morphSubtableHeader, LEErrorCode &success);
virtual ~IndicRearrangementProcessor2(); virtual ~IndicRearrangementProcessor2();
...@@ -76,8 +76,8 @@ public: ...@@ -76,8 +76,8 @@ public:
static UClassID getStaticClassID(); static UClassID getStaticClassID();
protected: protected:
le_int32 firstGlyph; le_uint32 firstGlyph;
le_int32 lastGlyph; le_uint32 lastGlyph;
LEReferenceToArrayOf<IndicRearrangementStateEntry2> entryTable; LEReferenceToArrayOf<IndicRearrangementStateEntry2> entryTable;
LEReferenceTo<IndicRearrangementSubtableHeader2> indicRearrangementSubtableHeader; LEReferenceTo<IndicRearrangementSubtableHeader2> indicRearrangementSubtableHeader;
......
...@@ -75,6 +75,7 @@ void MorphTableHeader::process(const LETableReference &base, LEGlyphStorage &gly ...@@ -75,6 +75,7 @@ void MorphTableHeader::process(const LETableReference &base, LEGlyphStorage &gly
return; return;
} }
subtableHeader.addOffset(length, success); subtableHeader.addOffset(length, success);
if (LE_FAILURE(success)) break;
} }
SubtableCoverage coverage = SWAPW(subtableHeader->coverage); SubtableCoverage coverage = SWAPW(subtableHeader->coverage);
FeatureFlags subtableFeatures = SWAPL(subtableHeader->subtableFeatures); FeatureFlags subtableFeatures = SWAPL(subtableHeader->subtableFeatures);
...@@ -91,6 +92,8 @@ void MorphSubtableHeader::process(const LEReferenceTo<MorphSubtableHeader> &base ...@@ -91,6 +92,8 @@ void MorphSubtableHeader::process(const LEReferenceTo<MorphSubtableHeader> &base
{ {
SubtableProcessor *processor = NULL; SubtableProcessor *processor = NULL;
if (LE_FAILURE(success)) return;
switch (SWAPW(coverage) & scfTypeMask) switch (SWAPW(coverage) & scfTypeMask)
{ {
case mstIndicRearrangement: case mstIndicRearrangement:
......
...@@ -197,6 +197,7 @@ void MorphTableHeader2::process(const LEReferenceTo<MorphTableHeader2> &base, LE ...@@ -197,6 +197,7 @@ void MorphTableHeader2::process(const LEReferenceTo<MorphTableHeader2> &base, LE
return; return;
} }
subtableHeader.addOffset(length, success); // Don't addOffset for the last entry. subtableHeader.addOffset(length, success); // Don't addOffset for the last entry.
if (LE_FAILURE(success)) break;
} }
le_uint32 coverage = SWAPL(subtableHeader->coverage); le_uint32 coverage = SWAPL(subtableHeader->coverage);
FeatureFlags subtableFeatures = SWAPL(subtableHeader->subtableFeatures); FeatureFlags subtableFeatures = SWAPL(subtableHeader->subtableFeatures);
...@@ -212,6 +213,8 @@ void MorphSubtableHeader2::process(const LEReferenceTo<MorphSubtableHeader2> &ba ...@@ -212,6 +213,8 @@ void MorphSubtableHeader2::process(const LEReferenceTo<MorphSubtableHeader2> &ba
{ {
SubtableProcessor2 *processor = NULL; SubtableProcessor2 *processor = NULL;
if (LE_FAILURE(success)) return;
switch (SWAPL(coverage) & scfTypeMask2) switch (SWAPL(coverage) & scfTypeMask2)
{ {
case mstIndicRearrangement: case mstIndicRearrangement:
......
...@@ -63,6 +63,8 @@ void SegmentArrayProcessor::process(LEGlyphStorage &glyphStorage, LEErrorCode &s ...@@ -63,6 +63,8 @@ void SegmentArrayProcessor::process(LEGlyphStorage &glyphStorage, LEErrorCode &s
le_int32 glyphCount = glyphStorage.getGlyphCount(); le_int32 glyphCount = glyphStorage.getGlyphCount();
le_int32 glyph; le_int32 glyph;
if (LE_FAILURE(success)) return;
for (glyph = 0; glyph < glyphCount; glyph += 1) { for (glyph = 0; glyph < glyphCount; glyph += 1) {
LEGlyphID thisGlyph = glyphStorage[glyph]; LEGlyphID thisGlyph = glyphStorage[glyph];
const LookupSegment *lookupSegment = segmentArrayLookupTable->lookupSegment(segmentArrayLookupTable, segments, thisGlyph, success); const LookupSegment *lookupSegment = segmentArrayLookupTable->lookupSegment(segmentArrayLookupTable, segments, thisGlyph, success);
......
...@@ -63,6 +63,8 @@ void SegmentArrayProcessor2::process(LEGlyphStorage &glyphStorage, LEErrorCode & ...@@ -63,6 +63,8 @@ void SegmentArrayProcessor2::process(LEGlyphStorage &glyphStorage, LEErrorCode &
le_int32 glyphCount = glyphStorage.getGlyphCount(); le_int32 glyphCount = glyphStorage.getGlyphCount();
le_int32 glyph; le_int32 glyph;
if (LE_FAILURE(success)) return;
for (glyph = 0; glyph < glyphCount; glyph += 1) { for (glyph = 0; glyph < glyphCount; glyph += 1) {
LEGlyphID thisGlyph = glyphStorage[glyph]; LEGlyphID thisGlyph = glyphStorage[glyph];
// lookupSegment already range checked by lookupSegment() function. // lookupSegment already range checked by lookupSegment() function.
......
...@@ -64,6 +64,8 @@ void SegmentSingleProcessor2::process(LEGlyphStorage &glyphStorage, LEErrorCode ...@@ -64,6 +64,8 @@ void SegmentSingleProcessor2::process(LEGlyphStorage &glyphStorage, LEErrorCode
le_int32 glyphCount = glyphStorage.getGlyphCount(); le_int32 glyphCount = glyphStorage.getGlyphCount();
le_int32 glyph; le_int32 glyph;
if (LE_FAILURE(success)) return;
for (glyph = 0; glyph < glyphCount; glyph += 1) { for (glyph = 0; glyph < glyphCount; glyph += 1) {
LEGlyphID thisGlyph = glyphStorage[glyph]; LEGlyphID thisGlyph = glyphStorage[glyph];
const LookupSegment *lookupSegment = segmentSingleLookupTable->lookupSegment(segmentSingleLookupTable, segments, thisGlyph, success); const LookupSegment *lookupSegment = segmentSingleLookupTable->lookupSegment(segmentSingleLookupTable, segments, thisGlyph, success);
......
...@@ -61,10 +61,11 @@ SimpleArrayProcessor2::~SimpleArrayProcessor2() ...@@ -61,10 +61,11 @@ SimpleArrayProcessor2::~SimpleArrayProcessor2()
void SimpleArrayProcessor2::process(LEGlyphStorage &glyphStorage, LEErrorCode &success) void SimpleArrayProcessor2::process(LEGlyphStorage &glyphStorage, LEErrorCode &success)
{ {
if (LE_FAILURE(success)) return;
le_int32 glyphCount = glyphStorage.getGlyphCount(); le_int32 glyphCount = glyphStorage.getGlyphCount();
le_int32 glyph; le_int32 glyph;
if (LE_FAILURE(success)) return;
for (glyph = 0; glyph < glyphCount; glyph += 1) { for (glyph = 0; glyph < glyphCount; glyph += 1) {
LEGlyphID thisGlyph = glyphStorage[glyph]; LEGlyphID thisGlyph = glyphStorage[glyph];
if (LE_GET_GLYPH(thisGlyph) < 0xFFFF) { if (LE_GET_GLYPH(thisGlyph) < 0xFFFF) {
......
...@@ -63,6 +63,8 @@ void SingleTableProcessor::process(LEGlyphStorage &glyphStorage, LEErrorCode &su ...@@ -63,6 +63,8 @@ void SingleTableProcessor::process(LEGlyphStorage &glyphStorage, LEErrorCode &su
le_int32 glyph; le_int32 glyph;
le_int32 glyphCount = glyphStorage.getGlyphCount(); le_int32 glyphCount = glyphStorage.getGlyphCount();
if (LE_FAILURE(success)) return;
for (glyph = 0; glyph < glyphCount; glyph += 1) { for (glyph = 0; glyph < glyphCount; glyph += 1) {
const LookupSingle *lookupSingle = singleTableLookupTable->lookupSingle(singleTableLookupTable, entries, glyphStorage[glyph], success); const LookupSingle *lookupSingle = singleTableLookupTable->lookupSingle(singleTableLookupTable, entries, glyphStorage[glyph], success);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册