From: Andreas Gal Date: Thu, 12 May 2011 06:00:36 +0000 (-0700) Subject: clone stream if we got it from the cache in case its already in use X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=fed7e723b8896f93d5c4675c356b3e29cde7e0fa;p=pdf.js.git clone stream if we got it from the cache in case its already in use --- diff --git a/pdf.js b/pdf.js index efca6b9..750cec1 100644 --- 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())) {