gracefully handle bogus stringOffset values (thanks to Anthony Fok)
git-svn-id: svn://svn.code.sf.net/p/fonttools/code/trunk@387 4cde692c-a291-49d1-8350-778aa11640f8
This commit is contained in:
parent
1332d3e549
commit
aabca6d793
@ -14,11 +14,19 @@ nameRecordFormat = """
|
|||||||
offset: H
|
offset: H
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
nameRecordSize = sstruct.calcsize(nameRecordFormat)
|
||||||
|
|
||||||
|
|
||||||
class table__n_a_m_e(DefaultTable.DefaultTable):
|
class table__n_a_m_e(DefaultTable.DefaultTable):
|
||||||
|
|
||||||
def decompile(self, data, ttFont):
|
def decompile(self, data, ttFont):
|
||||||
format, n, stringoffset = struct.unpack(">HHH", data[:6])
|
format, n, stringoffset = struct.unpack(">HHH", data[:6])
|
||||||
stringoffset = int(stringoffset)
|
expectedStringOffset = 6 + n * nameRecordSize
|
||||||
|
if stringoffset != expectedStringOffset:
|
||||||
|
# XXX we need a warn function
|
||||||
|
print "Warning: 'name' table stringoffset incorrect.",
|
||||||
|
print "Expected: %s; Actual: %s" % (expectedStringOffset, stringoffset)
|
||||||
|
stringoffset = expectedStringOffset
|
||||||
stringData = data[stringoffset:]
|
stringData = data[stringoffset:]
|
||||||
data = data[6:stringoffset]
|
data = data[6:stringoffset]
|
||||||
self.names = []
|
self.names = []
|
||||||
|
Loading…
x
Reference in New Issue
Block a user