[Pkg-javascript-commits] [pdf.js] 397/414: Adjust incorrect first obj number of "free" xref entry in `XRef_readXRefTable` (issue 7229)

David Prévot taffit at moszumanska.debian.org
Tue Jun 28 17:12:44 UTC 2016


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository pdf.js.

commit e281ef15dba06d2a4159373d2384224ce6bf10b0
Author: Jonas Jenwald <jonas.jenwald at gmail.com>
Date:   Thu Apr 21 15:10:40 2016 +0200

    Adjust incorrect first obj number of "free" xref entry in `XRef_readXRefTable` (issue 7229)
    
    Fixes 7229.
---
 src/core/obj.js         |  12 ++++++------
 test/pdfs/.gitignore    |   1 +
 test/pdfs/issue7229.pdf | Bin 0 -> 1153154 bytes
 test/test_manifest.json |   8 ++++++++
 4 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/src/core/obj.js b/src/core/obj.js
index 830ed6c..fc5c52d 100644
--- a/src/core/obj.js
+++ b/src/core/obj.js
@@ -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');
diff --git a/test/pdfs/.gitignore b/test/pdfs/.gitignore
index 47c821f..82bc7d1 100644
--- a/test/pdfs/.gitignore
+++ b/test/pdfs/.gitignore
@@ -24,6 +24,7 @@
 !issue7101.pdf
 !issue7115.pdf
 !issue7200.pdf
+!issue7229.pdf
 !filled-background.pdf
 !ArabicCIDTrueType.pdf
 !ThuluthFeatures.pdf
diff --git a/test/pdfs/issue7229.pdf b/test/pdfs/issue7229.pdf
new file mode 100644
index 0000000..784f555
Binary files /dev/null and b/test/pdfs/issue7229.pdf differ
diff --git a/test/test_manifest.json b/test/test_manifest.json
index e3c827c..e2d11c0 100644
--- a/test/test_manifest.json
+++ b/test/test_manifest.json
@@ -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",

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/pdf.js.git



More information about the Pkg-javascript-commits mailing list