poppler/PDFDoc.cc | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-)
New commits: commit 173f182fb568843f97e7d45d1b16bebbd2aa7413 Author: Li Junling <[email protected]> Date: Fri Jan 2 17:23:24 2015 +0100 Find last 'startxref' in the last 24K instead of the last 1K Bug #85919 diff --git a/poppler/PDFDoc.cc b/poppler/PDFDoc.cc index ec8d3df..b6af8e8 100644 --- a/poppler/PDFDoc.cc +++ b/poppler/PDFDoc.cc @@ -1820,27 +1820,33 @@ Goffset PDFDoc::getStartXRef(GBool tryingToReconstruct) int c, n, i; // read last xrefSearchSize bytes - str->setPos(xrefSearchSize, -1); - for (n = 0; n < xrefSearchSize; ++n) { - if ((c = str->getChar()) == EOF) { - break; + int segnum = 0; + int maxXRefSearch = 24576; + if (str->getLength() < maxXRefSearch) maxXRefSearch = str->getLength(); + 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 - for (i = n - 9; i >= 0; --i) { - if (!strncmp(&buf[i], "startxref", 9)) { + // find startxref + for (i = n - 9; i >= 0; --i) { + 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; } } - if (i < 0) { - startXRefPos = 0; - } else { - for (p = &buf[i+9]; isspace(*p); ++p) ; - startXRefPos = strToLongLong(p); - } } } _______________________________________________ poppler mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/poppler
