avoids crash in pdf syntax error for missing ids

when an object id is out of range, rather than crashing, only raise a
pdf syntax error if STRICT is enabled and return None otherwise
pull/1/head
dwilson 2011-08-31 17:03:10 -04:00
parent cbb8d869c7
commit 60dbf6bb69
1 changed files with 4 additions and 1 deletions

View File

@ -454,7 +454,10 @@ class PDFDocument(object):
try: try:
obj = objs[i] obj = objs[i]
except IndexError: except IndexError:
raise PDFSyntaxError('Invalid object number: objid=%r' % (objid)) if STRICT:
raise PDFSyntaxError('Invalid object number: objid=%r' % (objid))
# return None for an invalid object number
return None
if isinstance(obj, PDFStream): if isinstance(obj, PDFStream):
obj.set_objid(objid, 0) obj.set_objid(objid, 0)
else: else: