Possible fix to some RotSprite crashes (#2780)

This commit is contained in:
David Capello 2023-11-21 12:58:31 -03:00
parent 55e65a1f8b
commit eafb779ef0
1 changed files with 5 additions and 2 deletions

View File

@ -1,5 +1,5 @@
// Aseprite Document Library
// Copyright (c) 2020-2022 Igara Studio S.A.
// Copyright (c) 2020-2023 Igara Studio S.A.
// Copyright (c) 2001-2018 David Capello
//
// This file is released under the terms of the MIT license.
@ -221,7 +221,10 @@ void rotsprite_image(Image* bmp, const Image* spr, const Image* mask,
(x3-xmin)*scale, (y3-ymin)*scale, (x4-xmin)*scale, (y4-ymin)*scale);
scale_image(bmp, bmp_copy.get(),
xmin, ymin, rot_width, rot_height,
std::max(0, xmin),
std::max(0, ymin),
std::clamp(rot_width, 0, std::max(0, bmp->width() - std::max(0, xmin))),
std::clamp(rot_height, 0, std::max(0, bmp->height() - std::max(0, ymin))),
0, 0, bmp_copy->width(), bmp_copy->height());
}