Skip to content

Commit dd705eb

Browse files
committed
prevent potential overflow
1 parent 7ab7b22 commit dd705eb

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/ImageSharp/Processing/Processors/Drawing/DrawImageProcessor{TPixelBg,TPixelFg}.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,14 @@ protected override void OnFrameApply(ImageFrame<TPixelBg> source)
9696
top = 0;
9797
}
9898

99-
if (left + foregroundRectangle.Width > source.Width)
99+
if (left > source.Width - foregroundRectangle.Width)
100100
{
101101
// will overhange, lets trim it down
102102
int diff = (left + foregroundRectangle.Width) - source.Width;
103103
foregroundRectangle.Width -= diff;
104104
}
105105

106-
if (top + foregroundRectangle.Height > source.Height)
106+
if (top > source.Height - foregroundRectangle.Height)
107107
{
108108
// will overhange, lets trim it down
109109
int diff = (top + foregroundRectangle.Height) - source.Height;

0 commit comments

Comments
 (0)