76f8c5
commit d6ea8acbb348fdb43601a963ba5407e933565003
76f8c5
Author: Adrian Johnson <ajohnson@redneon.com>
76f8c5
Date:   Mon Nov 3 19:11:25 2014 +0100
76f8c5
76f8c5
    fix crash in Xref::getEntry
76f8c5
    
76f8c5
    Bug 85234
76f8c5
76f8c5
diff --git a/poppler/XRef.cc b/poppler/XRef.cc
76f8c5
index 2560e3d..333f5ec 100644
76f8c5
--- a/poppler/XRef.cc
76f8c5
+++ b/poppler/XRef.cc
76f8c5
@@ -1568,7 +1568,7 @@ GBool XRef::parseEntry(Goffset offset, XRefEntry *entry)
76f8c5
 void XRef::readXRefUntil(int untilEntryNum, std::vector<int> *xrefStreamObjsNum)
76f8c5
 {
76f8c5
   std::vector<Goffset> followedPrev;
76f8c5
-  while (prevXRefOffset && (untilEntryNum == -1 || entries[untilEntryNum].type == xrefEntryNone)) {
76f8c5
+  while (prevXRefOffset && (untilEntryNum == -1 || (untilEntryNum < size && entries[untilEntryNum].type == xrefEntryNone))) {
76f8c5
     bool followed = false;
76f8c5
     for (size_t j = 0; j < followedPrev.size(); j++) {
76f8c5
       if (followedPrev.at(j) == prevXRefOffset) {
76f8c5
@@ -1606,7 +1606,7 @@ void XRef::readXRefUntil(int untilEntryNum, std::vector<int> *xrefStreamObjsNum)
76f8c5
 
76f8c5
 XRefEntry *XRef::getEntry(int i, GBool complainIfMissing)
76f8c5
 {
76f8c5
-  if (entries[i].type == xrefEntryNone) {
76f8c5
+  if (i >= size || entries[i].type == xrefEntryNone) {
76f8c5
 
76f8c5
     if ((!xRefStream) && mainXRefEntriesOffset) {
76f8c5
       if (!parseEntry(mainXRefEntriesOffset + 20*i, &entries[i])) {