/*
*
- * (C) Copyright IBM Corp. 1998-2013 - All Rights Reserved
+ * (C) Copyright IBM Corp. 1998-2015 - All Rights Reserved
*
*/
IndicRearrangementFlags flags = (IndicRearrangementFlags) SWAPW(entry->flags);
if (flags & irfMarkFirst) {
- firstGlyph = currGlyph;
+ firstGlyph = (le_uint32)currGlyph;
}
if (flags & irfMarkLast) {
- lastGlyph = currGlyph;
+ lastGlyph = (le_uint32)currGlyph;
}
- doRearrangementAction(glyphStorage, (IndicRearrangementVerb) (flags & irfVerbMask));
+ doRearrangementAction(glyphStorage, (IndicRearrangementVerb) (flags & irfVerbMask), success);
if (!(flags & irfDontAdvance)) {
// XXX: Should handle reverse too...
{
}
-void IndicRearrangementProcessor::doRearrangementAction(LEGlyphStorage &glyphStorage, IndicRearrangementVerb verb) const
+void IndicRearrangementProcessor::doRearrangementAction(LEGlyphStorage &glyphStorage, IndicRearrangementVerb verb, LEErrorCode &success) const
{
LEGlyphID a, b, c, d;
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)
{
- case irvNoAction:
- break;
-
case irvxA:
+ if (firstGlyph == lastGlyph) break;
+ if (firstGlyph + 1 < firstGlyph) {
+ success = LE_INDEX_OUT_OF_BOUNDS_ERROR;
+ break;
+ }
a = glyphStorage[firstGlyph];
ia = glyphStorage.getCharIndex(firstGlyph, success);
x = firstGlyph + 1;
break;
case irvDx:
+ if (firstGlyph == lastGlyph) break;
+ if (lastGlyph - 1 > lastGlyph) {
+ success = LE_INDEX_OUT_OF_BOUNDS_ERROR;
+ break;
+ }
d = glyphStorage[lastGlyph];
id = glyphStorage.getCharIndex(lastGlyph, success);
x = lastGlyph - 1;
break;
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];
b = glyphStorage[firstGlyph + 1];
ia = glyphStorage.getCharIndex(firstGlyph, success);
break;
case irvxBA:
+ if ((firstGlyph + 2 < firstGlyph) ||
+ (lastGlyph - firstGlyph < 1)) {
+ success = LE_INDEX_OUT_OF_BOUNDS_ERROR;
+ break;
+ }
a = glyphStorage[firstGlyph];
b = glyphStorage[firstGlyph + 1];
ia = glyphStorage.getCharIndex(firstGlyph, success);
break;
case irvCDx:
+ if ((lastGlyph - 2 > lastGlyph) ||
+ (lastGlyph - firstGlyph < 1)) {
+ success = LE_INDEX_OUT_OF_BOUNDS_ERROR;
+ break;
+ }
c = glyphStorage[lastGlyph - 1];
d = glyphStorage[lastGlyph];
ic = glyphStorage.getCharIndex(lastGlyph - 1, success);
break;
case irvDCx:
+ if ((lastGlyph - 2 > lastGlyph) ||
+ (lastGlyph - firstGlyph < 1)) {
+ success = LE_INDEX_OUT_OF_BOUNDS_ERROR;
+ break;
+ }
c = glyphStorage[lastGlyph - 1];
d = glyphStorage[lastGlyph];
ic = glyphStorage.getCharIndex(lastGlyph - 1, success);
break;
case irvCDxA:
+ if ((lastGlyph - 2 > lastGlyph) ||
+ (lastGlyph - firstGlyph < 2)) {
+ success = LE_INDEX_OUT_OF_BOUNDS_ERROR;
+ break;
+ }
a = glyphStorage[firstGlyph];
c = glyphStorage[lastGlyph - 1];
d = glyphStorage[lastGlyph];
break;
case irvDCxA:
+ if ((lastGlyph - 2 > lastGlyph) ||
+ (lastGlyph - firstGlyph < 2)) {
+ success = LE_INDEX_OUT_OF_BOUNDS_ERROR;
+ break;
+ }
a = glyphStorage[firstGlyph];
c = glyphStorage[lastGlyph - 1];
d = glyphStorage[lastGlyph];
break;
case irvDxAB:
+ if ((firstGlyph + 2 < firstGlyph) ||
+ (lastGlyph - firstGlyph < 2)) {
+ success = LE_INDEX_OUT_OF_BOUNDS_ERROR;
+ break;
+ }
a = glyphStorage[firstGlyph];
b = glyphStorage[firstGlyph + 1];
d = glyphStorage[lastGlyph];
break;
case irvDxBA:
+ if ((firstGlyph + 2 < firstGlyph) ||
+ (lastGlyph - firstGlyph < 2)) {
+ success = LE_INDEX_OUT_OF_BOUNDS_ERROR;
+ break;
+ }
a = glyphStorage[firstGlyph];
b = glyphStorage[firstGlyph + 1];
d = glyphStorage[lastGlyph];
break;
case irvCDxAB:
+ if (lastGlyph - firstGlyph < 3) {
+ success = LE_INDEX_OUT_OF_BOUNDS_ERROR;
+ break;
+ }
a = glyphStorage[firstGlyph];
b = glyphStorage[firstGlyph + 1];
break;
case irvCDxBA:
+ if (lastGlyph - firstGlyph < 3) {
+ success = LE_INDEX_OUT_OF_BOUNDS_ERROR;
+ break;
+ }
a = glyphStorage[firstGlyph];
b = glyphStorage[firstGlyph + 1];
break;
case irvDCxAB:
+ if (lastGlyph - firstGlyph < 3) {
+ success = LE_INDEX_OUT_OF_BOUNDS_ERROR;
+ break;
+ }
a = glyphStorage[firstGlyph];
b = glyphStorage[firstGlyph + 1];
break;
case irvDCxBA:
+ if (lastGlyph - firstGlyph < 3) {
+ success = LE_INDEX_OUT_OF_BOUNDS_ERROR;
+ break;
+ }
a = glyphStorage[firstGlyph];
b = glyphStorage[firstGlyph + 1];
/*
*
- * (C) Copyright IBM Corp. 1998-2014 - All Rights Reserved
+ * (C) Copyright IBM Corp. 1998-2015 - All Rights Reserved
*
*/
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);
virtual ~IndicRearrangementProcessor();
static UClassID getStaticClassID();
protected:
- le_int32 firstGlyph;
- le_int32 lastGlyph;
+ le_uint32 firstGlyph;
+ le_uint32 lastGlyph;
LEReferenceTo<IndicRearrangementSubtableHeader> indicRearrangementSubtableHeader;
LEReferenceToArrayOf<IndicRearrangementStateEntry> entryTable;
/*
*
- * (C) Copyright IBM Corp. and others 1998-2014 - All Rights Reserved
+ * (C) Copyright IBM Corp. and others 1998-2015 - All Rights Reserved
*
*/
IndicRearrangementFlags flags = (IndicRearrangementFlags) SWAPW(entry->flags);
if (flags & irfMarkFirst) {
- firstGlyph = currGlyph;
+ firstGlyph = (le_uint32)currGlyph;
}
if (flags & irfMarkLast) {
- lastGlyph = currGlyph;
+ lastGlyph = (le_uint32)currGlyph;
}
- doRearrangementAction(glyphStorage, (IndicRearrangementVerb) (flags & irfVerbMask));
+ doRearrangementAction(glyphStorage, (IndicRearrangementVerb) (flags & irfVerbMask), success);
if (!(flags & irfDontAdvance)) {
currGlyph += dir;
{
}
-void IndicRearrangementProcessor2::doRearrangementAction(LEGlyphStorage &glyphStorage, IndicRearrangementVerb verb) const
+void IndicRearrangementProcessor2::doRearrangementAction(LEGlyphStorage &glyphStorage, IndicRearrangementVerb verb, LEErrorCode &success) const
{
LEGlyphID a, b, c, d;
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)
{
- case irvNoAction:
- break;
-
case irvxA:
+ if (firstGlyph == lastGlyph) break;
+ if (firstGlyph + 1 < firstGlyph) {
+ success = LE_INDEX_OUT_OF_BOUNDS_ERROR;
+ break;
+ }
a = glyphStorage[firstGlyph];
ia = glyphStorage.getCharIndex(firstGlyph, success);
x = firstGlyph + 1;
break;
case irvDx:
+ if (firstGlyph == lastGlyph) break;
+ if (lastGlyph - 1 > lastGlyph) {
+ success = LE_INDEX_OUT_OF_BOUNDS_ERROR;
+ break;
+ }
d = glyphStorage[lastGlyph];
id = glyphStorage.getCharIndex(lastGlyph, success);
x = lastGlyph - 1;
break;
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];
b = glyphStorage[firstGlyph + 1];
ia = glyphStorage.getCharIndex(firstGlyph, success);
break;
case irvxBA:
+ if ((firstGlyph + 2 < firstGlyph) ||
+ (lastGlyph - firstGlyph < 1)) {
+ success = LE_INDEX_OUT_OF_BOUNDS_ERROR;
+ break;
+ }
a = glyphStorage[firstGlyph];
b = glyphStorage[firstGlyph + 1];
ia = glyphStorage.getCharIndex(firstGlyph, success);
break;
case irvCDx:
+ if ((lastGlyph - 2 > lastGlyph) ||
+ (lastGlyph - firstGlyph < 1)) {
+ success = LE_INDEX_OUT_OF_BOUNDS_ERROR;
+ break;
+ }
c = glyphStorage[lastGlyph - 1];
d = glyphStorage[lastGlyph];
ic = glyphStorage.getCharIndex(lastGlyph - 1, success);
break;
case irvDCx:
+ if ((lastGlyph - 2 > lastGlyph) ||
+ (lastGlyph - firstGlyph < 1)) {
+ success = LE_INDEX_OUT_OF_BOUNDS_ERROR;
+ break;
+ }
c = glyphStorage[lastGlyph - 1];
d = glyphStorage[lastGlyph];
ic = glyphStorage.getCharIndex(lastGlyph - 1, success);
break;
case irvCDxA:
+ if ((lastGlyph - 2 > lastGlyph) ||
+ (lastGlyph - firstGlyph < 2)) {
+ success = LE_INDEX_OUT_OF_BOUNDS_ERROR;
+ break;
+ }
a = glyphStorage[firstGlyph];
c = glyphStorage[lastGlyph - 1];
d = glyphStorage[lastGlyph];
break;
case irvDCxA:
+ if ((lastGlyph - 2 > lastGlyph) ||
+ (lastGlyph - firstGlyph < 2)) {
+ success = LE_INDEX_OUT_OF_BOUNDS_ERROR;
+ break;
+ }
a = glyphStorage[firstGlyph];
c = glyphStorage[lastGlyph - 1];
d = glyphStorage[lastGlyph];
break;
case irvDxAB:
+ if ((firstGlyph + 2 < firstGlyph) ||
+ (lastGlyph - firstGlyph < 2)) {
+ success = LE_INDEX_OUT_OF_BOUNDS_ERROR;
+ break;
+ }
a = glyphStorage[firstGlyph];
b = glyphStorage[firstGlyph + 1];
d = glyphStorage[lastGlyph];
break;
case irvDxBA:
+ if ((firstGlyph + 2 < firstGlyph) ||
+ (lastGlyph - firstGlyph < 2)) {
+ success = LE_INDEX_OUT_OF_BOUNDS_ERROR;
+ break;
+ }
a = glyphStorage[firstGlyph];
b = glyphStorage[firstGlyph + 1];
d = glyphStorage[lastGlyph];
break;
case irvCDxAB:
+ if (lastGlyph - firstGlyph < 3) {
+ success = LE_INDEX_OUT_OF_BOUNDS_ERROR;
+ break;
+ }
a = glyphStorage[firstGlyph];
b = glyphStorage[firstGlyph + 1];
break;
case irvCDxBA:
+ if (lastGlyph - firstGlyph < 3) {
+ success = LE_INDEX_OUT_OF_BOUNDS_ERROR;
+ break;
+ }
a = glyphStorage[firstGlyph];
b = glyphStorage[firstGlyph + 1];
break;
case irvDCxAB:
+ if (lastGlyph - firstGlyph < 3) {
+ success = LE_INDEX_OUT_OF_BOUNDS_ERROR;
+ break;
+ }
a = glyphStorage[firstGlyph];
b = glyphStorage[firstGlyph + 1];
break;
case irvDCxBA:
+ if (lastGlyph - firstGlyph < 3) {
+ success = LE_INDEX_OUT_OF_BOUNDS_ERROR;
+ break;
+ }
a = glyphStorage[firstGlyph];
b = glyphStorage[firstGlyph + 1];
/*
*
- * (C) Copyright IBM Corp. and others 1998-2014 - All Rights Reserved
+ * (C) Copyright IBM Corp. and others 1998-2015 - All Rights Reserved
*
*/
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);
virtual ~IndicRearrangementProcessor2();
static UClassID getStaticClassID();
protected:
- le_int32 firstGlyph;
- le_int32 lastGlyph;
+ le_uint32 firstGlyph;
+ le_uint32 lastGlyph;
LEReferenceToArrayOf<IndicRearrangementStateEntry2> entryTable;
LEReferenceTo<IndicRearrangementSubtableHeader2> indicRearrangementSubtableHeader;
/*
* %W% %W%
*
- * (C) Copyright IBM Corp. 1998 - 2013 - All Rights Reserved
+ * (C) Copyright IBM Corp. 1998 - 2015 - All Rights Reserved
*
*/
{
SubtableProcessor *processor = NULL;
+ if (LE_FAILURE(success)) return;
+
switch (SWAPW(coverage) & scfTypeMask)
{
case mstIndicRearrangement:
/*
- * (C) Copyright IBM Corp. and others 1998 - 2013 - All Rights Reserved
+ * (C) Copyright IBM Corp. and others 1998 - 2015 - All Rights Reserved
*
*/
if(subtable>0) {
le_uint32 length = SWAPL(subtableHeader->length);
subtableHeader.addOffset(length, success); // Don't addOffset for the last entry.
+ if (LE_FAILURE(success)) break;
}
le_uint32 coverage = SWAPL(subtableHeader->coverage);
FeatureFlags subtableFeatures = SWAPL(subtableHeader->subtableFeatures);
{
SubtableProcessor2 *processor = NULL;
+ if (LE_FAILURE(success)) return;
+
switch (SWAPL(coverage) & scfTypeMask2)
{
case mstIndicRearrangement:
/*
*
- * (C) Copyright IBM Corp. 1998-2013 - All Rights Reserved
+ * (C) Copyright IBM Corp. 1998-2015 - All Rights Reserved
*
*/
le_int32 glyphCount = glyphStorage.getGlyphCount();
le_int32 glyph;
+ if (LE_FAILURE(success)) return;
+
for (glyph = 0; glyph < glyphCount; glyph += 1) {
LEGlyphID thisGlyph = glyphStorage[glyph];
const LookupSegment *lookupSegment = segmentArrayLookupTable->lookupSegment(segmentArrayLookupTable, segments, thisGlyph, success);
/*
*
- * (C) Copyright IBM Corp. and others 1998-2013 - All Rights Reserved
+ * (C) Copyright IBM Corp. and others 1998-2015 - All Rights Reserved
*
*/
le_int32 glyphCount = glyphStorage.getGlyphCount();
le_int32 glyph;
+ if (LE_FAILURE(success)) return;
+
for (glyph = 0; glyph < glyphCount; glyph += 1) {
LEGlyphID thisGlyph = glyphStorage[glyph];
const LookupSegment *lookupSegment = segmentArrayLookupTable->lookupSegment(segmentArrayLookupTable, segments, thisGlyph, success);
/*
*
- * (C) Copyright IBM Corp. and others 1998-2013 - All Rights Reserved
+ * (C) Copyright IBM Corp. and others 1998-2015 - All Rights Reserved
*
*/
le_int32 glyphCount = glyphStorage.getGlyphCount();
le_int32 glyph;
+ if (LE_FAILURE(success)) return;
+
for (glyph = 0; glyph < glyphCount; glyph += 1) {
LEGlyphID thisGlyph = glyphStorage[glyph];
const LookupSegment *lookupSegment = segmentSingleLookupTable->lookupSegment(segmentSingleLookupTable, segments, thisGlyph, success);
/*
*
- * (C) Copyright IBM Corp. and others 1998-2013 - All Rights Reserved
+ * (C) Copyright IBM Corp. and others 1998-2015 - All Rights Reserved
*
*/
void SimpleArrayProcessor2::process(LEGlyphStorage &glyphStorage, LEErrorCode &success)
{
- if (LE_FAILURE(success)) return;
le_int32 glyphCount = glyphStorage.getGlyphCount();
le_int32 glyph;
+ if (LE_FAILURE(success)) return;
+
for (glyph = 0; glyph < glyphCount; glyph += 1) {
LEGlyphID thisGlyph = glyphStorage[glyph];
if (LE_GET_GLYPH(thisGlyph) < 0xFFFF) {
/*
*
- * (C) Copyright IBM Corp. 1998-2013 - All Rights Reserved
+ * (C) Copyright IBM Corp. 1998-2015 - All Rights Reserved
*
*/
le_int32 glyph;
le_int32 glyphCount = glyphStorage.getGlyphCount();
+ if (LE_FAILURE(success)) return;
+
for (glyph = 0; glyph < glyphCount; glyph += 1) {
const LookupSingle *lookupSingle = singleTableLookupTable->lookupSingle(singleTableLookupTable, entries, glyphStorage[glyph], success);