From a0f27e8273f2cdcc24778e52b279da6f55fd03b3 Mon Sep 17 00:00:00 2001 From: Vitalii Savchuk Date: Sat, 25 Jun 2022 12:01:53 +0300 Subject: [PATCH] fixed memory leak when layer offset lower than mask offset --- src/display/canvas.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/display/canvas.js b/src/display/canvas.js index 98a6eec1fa9ec..29278d17e125c 100644 --- a/src/display/canvas.js +++ b/src/display/canvas.js @@ -1127,12 +1127,9 @@ function genericComposeSMask( const chunkSize = Math.min(height, Math.ceil(PIXELS_TO_PROCESS / width)); for (let row = 0; row < height; row += chunkSize) { const chunkHeight = Math.min(chunkSize, height - row); - const maskData = maskCtx.getImageData( - layerOffsetX - maskOffsetX, - row + (layerOffsetY - maskOffsetY), - width, - chunkHeight - ); + const maskX = Math.max(0, layerOffsetX - maskOffsetX); + const maskY = Math.max(0, row + (layerOffsetY - maskOffsetY)); + const maskData = maskCtx.getImageData(maskX, maskY, width, chunkHeight); const layerData = layerCtx.getImageData( layerOffsetX, row + layerOffsetY,