Commit 173f182f authored by Li Junling's avatar Li Junling Committed by Albert Astals Cid

Find last 'startxref' in the last 24K instead of the last 1K

Bug #85919
parent 0b1cd940
...@@ -1820,27 +1820,33 @@ Goffset PDFDoc::getStartXRef(GBool tryingToReconstruct) ...@@ -1820,27 +1820,33 @@ Goffset PDFDoc::getStartXRef(GBool tryingToReconstruct)
int c, n, i; int c, n, i;
// read last xrefSearchSize bytes // read last xrefSearchSize bytes
str->setPos(xrefSearchSize, -1); int segnum = 0;
for (n = 0; n < xrefSearchSize; ++n) { int maxXRefSearch = 24576;
if ((c = str->getChar()) == EOF) { if (str->getLength() < maxXRefSearch) maxXRefSearch = str->getLength();
break; for (; (xrefSearchSize - 16) * segnum < maxXRefSearch; segnum++) {
str->setPos((xrefSearchSize - 16) * segnum + xrefSearchSize, -1);
for (n = 0; n < xrefSearchSize; ++n) {
if ((c = str->getChar()) == EOF) {
break;
}
buf[n] = c;
} }
buf[n] = c; buf[n] = '\0';
}
buf[n] = '\0';
// find startxref // find startxref
for (i = n - 9; i >= 0; --i) { for (i = n - 9; i >= 0; --i) {
if (!strncmp(&buf[i], "startxref", 9)) { if (!strncmp(&buf[i], "startxref", 9)) {
break;
}
}
if (i < 0) {
startXRefPos = 0;
} else {
for (p = &buf[i + 9]; isspace(*p); ++p);
startXRefPos = strToLongLong(p);
break; break;
} }
} }
if (i < 0) {
startXRefPos = 0;
} else {
for (p = &buf[i+9]; isspace(*p); ++p) ;
startXRefPos = strToLongLong(p);
}
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment