3587f3
From b54e1fc3e0d2600621a28d50f9f085b9e38619c2 Mon Sep 17 00:00:00 2001
3587f3
From: Adam Reichold <adam.reichold@t-online.de>
3587f3
Date: Fri, 1 Feb 2019 08:42:27 +0100
3587f3
Subject: [PATCH] Also defend against requests for negative XRef indices.
3587f3
 oss-fuzz/12797
3587f3
3587f3
---
3587f3
 poppler/XRef.cc | 5 +++++
3587f3
 1 file changed, 5 insertions(+)
3587f3
3587f3
diff --git a/poppler/XRef.cc b/poppler/XRef.cc
3587f3
index d042d1f4..ac2cd0ce 100644
3587f3
--- a/poppler/XRef.cc
3587f3
+++ b/poppler/XRef.cc
3587f3
@@ -1565,6 +1565,11 @@ DummyXRefEntry dummyXRefEntry;
3587f3
 
3587f3
 XRefEntry *XRef::getEntry(int i, GBool complainIfMissing)
3587f3
 {
3587f3
+  if (unlikely(i < 0)) {
3587f3
+    error(errInternal, -1, "Request for invalid XRef entry [{0:d}]", i);
3587f3
+    return &dummyXRefEntry;
3587f3
+  }
3587f3
+
3587f3
   if (i >= size || entries[i].type == xrefEntryNone) {
3587f3
 
3587f3
     if ((!xRefStream) && mainXRefEntriesOffset) {
3587f3
-- 
3587f3
2.20.1
3587f3