]> git.parisson.com Git - pdf.js.git/commitdiff
Not relying on the xref in the parser
authornotmasteryet <async.processingjs@yahoo.com>
Wed, 15 Feb 2012 02:19:43 +0000 (20:19 -0600)
committernotmasteryet <async.processingjs@yahoo.com>
Wed, 15 Feb 2012 02:19:43 +0000 (20:19 -0600)
src/parser.js

index 35ec637a6132ba98a9710c7d31088c12d1fead93..fc448ff661fa915f265bb4b62850fa5f358717ca 100644 (file)
@@ -162,6 +162,10 @@ var Parser = (function ParserClosure() {
 
       return imageStream;
     },
+    fetchIfRef: function parserFetchIfRef(obj) {
+      // not relying on the xref.fetchIfRef -- xref might not be set
+      return isRef(obj) ? this.xref.fetch(obj) : obj;
+    },
     makeStream: function parserMakeStream(dict, cipherTransform) {
       var lexer = this.lexer;
       var stream = lexer.stream;
@@ -171,10 +175,7 @@ var Parser = (function ParserClosure() {
       var pos = stream.pos;
 
       // get length
-      var length = dict.get('Length');
-      var xref = this.xref;
-      if (xref)
-        length = xref.fetchIfRef(length);
+      var length = this.fetchIfRef(dict.get('Length'));
       if (!isInt(length)) {
         error('Bad ' + length + ' attribute in stream');
         length = 0;
@@ -196,9 +197,8 @@ var Parser = (function ParserClosure() {
       return stream;
     },
     filter: function parserFilter(stream, dict, length) {
-      var xref = this.xref;
-      var filter = xref.fetchIfRef(dict.get('Filter', 'F'));
-      var params = xref.fetchIfRef(dict.get('DecodeParms', 'DP'));
+      var filter = this.fetchIfRef(dict.get('Filter', 'F'));
+      var params = this.fetchIfRef(dict.get('DecodeParms', 'DP'));
       if (isName(filter))
         return this.makeFilter(stream, filter.name, length, params);
       if (isArray(filter)) {