]> git.parisson.com Git - pdf.js.git/commitdiff
hack around OOM problem due to broken pattern code
authorAndreas Gal <andreas.gal@gmail.com>
Sat, 25 Jun 2011 04:17:28 +0000 (00:17 -0400)
committerAndreas Gal <andreas.gal@gmail.com>
Sat, 25 Jun 2011 04:17:28 +0000 (00:17 -0400)
pdf.js

diff --git a/pdf.js b/pdf.js
index 68a2597d3693cdb5275fe8378b55e24e89e63da5..d06d07e0e1dbc720eed820820847c9d267849170 100644 (file)
--- a/pdf.js
+++ b/pdf.js
@@ -3030,10 +3030,14 @@ var CanvasGraphics = (function() {
             // we want the canvas to be as large as the step size
             var botRight = applyMatrix([x0 + xstep, y0 + ystep], matrix);
 
-            var tmpCanvas = new this.ScratchCanvas(
-                Math.ceil(botRight[0] - topLeft[0]),    // width
-                Math.ceil(botRight[1] - topLeft[1])     // height
-            );
+            var width = botRight[0] - topLeft[0];
+            var height = botRight[1] - topLeft[1];
+
+            // TODO: hack to avoid OOM, remove then pattern code is fixed
+            if (Math.abs(width) > 8192 || Math.abs(height) > 8192)
+                return false;
+
+            var tmpCanvas = new this.ScratchCanvas(width, height);
 
             // set the new canvas element context as the graphics context
             var tmpCtx = tmpCanvas.getContext("2d");