Adjust incorrect first obj number of "free" xref entry in XRef_readXRefTable (issue 7229)

Fixes 7229.
This commit is contained in:
Jonas Jenwald 2016-04-21 15:10:40 +02:00
parent 2001953871
commit e281ef15db
4 changed files with 15 additions and 6 deletions

View File

@ -736,6 +736,12 @@ var XRef = (function XRefClosure() {
error('Invalid entry in XRef subsection: ' + first + ', ' + count);
}
// The first xref table entry, i.e. obj 0, should be free. Attempting
// to adjust an incorrect first obj # (fixes issue 3248 and 7229).
if (i === 0 && entry.free && first === 1) {
first = 0;
}
if (!this.entries[i + first]) {
this.entries[i + first] = entry;
}
@ -749,12 +755,6 @@ var XRef = (function XRefClosure() {
delete tableState.entryCount;
}
// Per issue 3248: hp scanners generate bad XRef
if (first === 1 && this.entries[1] && this.entries[1].free) {
// shifting the entries
this.entries.shift();
}
// Sanity check: as per spec, first object must be free
if (this.entries[0] && !this.entries[0].free) {
error('Invalid XRef table: unexpected first object');

View File

@ -24,6 +24,7 @@
!issue7101.pdf
!issue7115.pdf
!issue7200.pdf
!issue7229.pdf
!filled-background.pdf
!ArabicCIDTrueType.pdf
!ThuluthFeatures.pdf

BIN
test/pdfs/issue7229.pdf Normal file

Binary file not shown.

View File

@ -1248,6 +1248,14 @@
"lastPage": 1,
"type": "eq"
},
{ "id": "issue7229",
"file": "pdfs/issue7229.pdf",
"md5": "480e51aae0ac271780e4603d1561d15e",
"rounds": 1,
"link": false,
"lastPage": 1,
"type": "load"
},
{ "id": "issue1940",
"file": "pdfs/issue1940.pdf",
"md5": "4f0a0b92c1b5e6e86e1a82490087e6e5",