distancefieldgenerator: Fix failure reading CMAP for some fonts

If all the range offsets in the type 4 subtable in CMAP
is equal to 0, there is no need for a glyph ID array, so
this array can actually have zero length.

We did not account for this, and would fail to read those
fonts.

Task-number: QTBUG-76188
Change-Id: I11873fba7214d179af1fcd7ccff9a9fd1c72ce10
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
This commit is contained in:
Eskil Abrahamsen Blomfeldt
2019-06-20 08:33:30 +00:00
parent a05eb13241
commit 73ecd39deb
@@ -148,7 +148,7 @@ void DistanceFieldModelWorker::readCmapSubtable(const CmapSubtable4 *subtable, c
const qint16 *idDeltas = reinterpret_cast<const qint16 *>(startCodes + segCount);
const quint16 *idRangeOffsets = reinterpret_cast<const quint16 *>(idDeltas + segCount);
const quint16 *glyphIdArray = idRangeOffsets + segCount;
if (glyphIdArray >= end) {
if (glyphIdArray > end) {
emit error(tr("End of cmap table reached when parsing subtable format '4'"));
return;
}