From 7a654efb5408e363ff293ccb77e6a5225f0a6348 Mon Sep 17 00:00:00 2001 From: David Huggins-Daines Date: Thu, 19 Sep 2024 00:30:52 -0400 Subject: [PATCH] fix: maybe fix some fuzz --- pdfminer/pdfparser.py | 7 ++++++- pdfminer/utils.py | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/pdfminer/pdfparser.py b/pdfminer/pdfparser.py index 645e0dec..dae1af59 100644 --- a/pdfminer/pdfparser.py +++ b/pdfminer/pdfparser.py @@ -146,7 +146,12 @@ def flush(self) -> None: def do_keyword(self, pos: int, token: PSKeyword) -> None: if token is self.KEYWORD_R: # reference to indirect object - (_, _object_id), _ = self.pop(2) + try: + (_, _object_id), _ = self.pop(2) + except ValueError: + raise PDFSyntaxError( + "Expected generation and object id in indirect object reference" + ) object_id = safe_int(_object_id) if object_id is not None: obj = PDFObjRef(self.doc, object_id) diff --git a/pdfminer/utils.py b/pdfminer/utils.py index 88b44b98..277cfe15 100644 --- a/pdfminer/utils.py +++ b/pdfminer/utils.py @@ -245,7 +245,7 @@ def parse_rect(o: Any) -> Rect: try: (x0, y0, x1, y1) = o return float(x0), float(y0), float(x1), float(y1) - except ValueError: + except (ValueError, TypeError): raise PDFValueError("Could not parse rectangle")