Fix reading of font names

Correct a boundary check so the last present name can be read, and
correct a typo that caused non-present names to read garbage.

Change-Id: Ia9d0d3af7431c1f5f02824e884efb5f6f454dc5d
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
This commit is contained in:
Allan Sandfeld Jensen 2016-08-18 13:11:46 +02:00 committed by Allan Sandfeld Jensen
parent e83f6aaaa6
commit eb19cf15a9

View File

@ -867,7 +867,7 @@ static FontNames getCanonicalFontNames(const uchar *table, quint32 bytes)
quint16 length = getUShort(names + 8 + i*NameRecordSize);
quint16 offset = getUShort(names + 10 + i*NameRecordSize);
if (DWORD(string_offset + offset + length) >= bytes)
if (DWORD(string_offset + offset + length) > bytes)
continue;
if ((platform_id == PlatformId_Microsoft
@ -890,7 +890,7 @@ static FontNames getCanonicalFontNames(const uchar *table, quint32 bytes)
QString strings[4];
for (int i = 0; i < 4; ++i) {
if (idStatus[0] == NotFound)
if (idStatus[i] == NotFound)
continue;
int id = ids[i];
quint16 length = getUShort(names + 8 + id * NameRecordSize);