From dd705eb0587f147f748aa0dec5032c2738f23327 Mon Sep 17 00:00:00 2001 From: Scott Williams Date: Sat, 9 Dec 2023 10:32:00 +0000 Subject: [PATCH] prevent potential overflow --- .../Drawing/DrawImageProcessor{TPixelBg,TPixelFg}.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ImageSharp/Processing/Processors/Drawing/DrawImageProcessor{TPixelBg,TPixelFg}.cs b/src/ImageSharp/Processing/Processors/Drawing/DrawImageProcessor{TPixelBg,TPixelFg}.cs index c51df8af8..e2aca1d90 100644 --- a/src/ImageSharp/Processing/Processors/Drawing/DrawImageProcessor{TPixelBg,TPixelFg}.cs +++ b/src/ImageSharp/Processing/Processors/Drawing/DrawImageProcessor{TPixelBg,TPixelFg}.cs @@ -96,14 +96,14 @@ internal class DrawImageProcessor : ImageProcessor top = 0; } - if (left + foregroundRectangle.Width > source.Width) + if (left > source.Width - foregroundRectangle.Width) { // will overhange, lets trim it down int diff = (left + foregroundRectangle.Width) - source.Width; foregroundRectangle.Width -= diff; } - if (top + foregroundRectangle.Height > source.Height) + if (top > source.Height - foregroundRectangle.Height) { // will overhange, lets trim it down int diff = (top + foregroundRectangle.Height) - source.Height;