Browse Source

prevent potential overflow

pull/2610/head
Scott Williams 2 years ago
parent
commit
dd705eb058
  1. 4
      src/ImageSharp/Processing/Processors/Drawing/DrawImageProcessor{TPixelBg,TPixelFg}.cs

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

@ -96,14 +96,14 @@ internal class DrawImageProcessor<TPixelBg, TPixelFg> : ImageProcessor<TPixelBg>
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;

Loading…
Cancel
Save