From 60dbf6bb69a1eef796b03c82377579368c473476 Mon Sep 17 00:00:00 2001 From: dwilson Date: Wed, 31 Aug 2011 17:03:10 -0400 Subject: [PATCH] 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 --- pdfminer/pdfparser.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pdfminer/pdfparser.py b/pdfminer/pdfparser.py index 1533826..f034e65 100644 --- a/pdfminer/pdfparser.py +++ b/pdfminer/pdfparser.py @@ -454,7 +454,10 @@ class PDFDocument(object): try: obj = objs[i] 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): obj.set_objid(objid, 0) else: