Blob Blame Raw
From b54e1fc3e0d2600621a28d50f9f085b9e38619c2 Mon Sep 17 00:00:00 2001
From: Adam Reichold <adam.reichold@t-online.de>
Date: Fri, 1 Feb 2019 08:42:27 +0100
Subject: [PATCH] Also defend against requests for negative XRef indices.
 oss-fuzz/12797

---
 poppler/XRef.cc | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/poppler/XRef.cc b/poppler/XRef.cc
index d042d1f4..ac2cd0ce 100644
--- a/poppler/XRef.cc
+++ b/poppler/XRef.cc
@@ -1565,6 +1565,11 @@ DummyXRefEntry dummyXRefEntry;
 
 XRefEntry *XRef::getEntry(int i, GBool complainIfMissing)
 {
+  if (unlikely(i < 0)) {
+    error(errInternal, -1, "Request for invalid XRef entry [{0:d}]", i);
+    return &dummyXRefEntry;
+  }
+
   if (i >= size || entries[i].type == xrefEntryNone) {
 
     if ((!xRefStream) && mainXRefEntriesOffset) {
-- 
2.20.1