From 378f381625a9373797955cd629c7b5488d40d544 Mon Sep 17 00:00:00 2001 From: Andreas Gal Date: Sat, 4 Jun 2011 23:18:55 -0700 Subject: [PATCH] don't cache stream objects --- pdf.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/pdf.js b/pdf.js index 0342ca66f..96dc518b5 100644 --- a/pdf.js +++ b/pdf.js @@ -1262,12 +1262,9 @@ var XRef = (function() { fetch: function(ref) { var num = ref.num; var e = this.cache[num]; - if (e) { - // The stream might be in use elsewhere, so clone it. - if (IsStream(e)) - e = e.makeSubStream(e.start, e.length, e.dict); + if (e) return e; - } + e = this.getEntry(num); var gen = ref.gen; if (e.uncompressed) { @@ -1292,7 +1289,11 @@ var XRef = (function() { } error("bad XRef entry"); } - return this.cache[num] = parser.getObj(); + e = parser.getObj(); + // Don't cache streams since they are mutable. + if (!IsStream(e)) + this.cache[num] = e; + return e; } error("compressed entry"); },