]> git.parisson.com Git - pdf.js.git/commitdiff
clone stream if we got it from the cache in case its already in use
authorAndreas Gal <andreas.gal@gmail.com>
Thu, 12 May 2011 06:00:36 +0000 (23:00 -0700)
committerAndreas Gal <andreas.gal@gmail.com>
Thu, 12 May 2011 06:00:36 +0000 (23:00 -0700)
pdf.js

diff --git a/pdf.js b/pdf.js
index efca6b987db6f28fce87dcffa1b56549b6122787..750cec1700213b6a554f55a05fabcd4a1d43298a 100644 (file)
--- a/pdf.js
+++ b/pdf.js
@@ -1739,8 +1739,12 @@ var XRef = (function() {
         fetch: function(ref) {
             var num = ref.num;
             var e = this.cache[num];
-            if (e)
+            if (e) {
+                // The stream might be in use elsewhere, so clone it.
+                if (IsStream(e))
+                    e = e.makeSubStream(0);
                 return e;
+            }
             e = this.getEntry(num);
             var gen = ref.gen;
             if (e.uncompressed) {
@@ -1810,7 +1814,6 @@ var Page = (function() {
                                height: mediaBox[3] - mediaBox[1] });
             var args = [];
             var map = gfx.map;
-            contents.reset();   // TODO support multiple display()s
             var parser = new Parser(new Lexer(contents), false);
             var obj;
             while (!IsEOF(obj = parser.getObj())) {