Skip to content

Commit

Permalink
prevent possible ssize overflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Cristy committed Jan 15, 2025
1 parent bf1e656 commit 8cbd11e
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions magick/transform.c
Original file line number Diff line number Diff line change
Expand Up @@ -686,24 +686,28 @@ MagickExport Image *CropImage(const Image *image,const RectangleInfo *geometry,
}
if ((page.x < 0) && (bounding_box.x >= 0))
{
page.width+=page.x-bounding_box.x;
page.width=CastDoubleToUnsigned((double) page.width+page.x-
bounding_box.x);
page.x=0;
}
else
{
page.width-=bounding_box.x-page.x;
page.width=CastDoubleToUnsigned((double) page.width-(bounding_box.x-
page.x));
page.x-=bounding_box.x;
if (page.x < 0)
page.x=0;
}
if ((page.y < 0) && (bounding_box.y >= 0))
{
page.height+=page.y-bounding_box.y;
page.height=CastDoubleToUnsigned((double) page.height+page.y-
bounding_box.y);
page.y=0;
}
else
{
page.height-=bounding_box.y-page.y;
page.height=CastDoubleToUnsigned((double) page.height-(bounding_box.y-
page.y));
page.y-=bounding_box.y;
if (page.y < 0)
page.y=0;
Expand Down

0 comments on commit 8cbd11e

Please sign in to comment.