Fix div by zero crash dropping image (fix #5447)

This commit is contained in:
David Capello 2025-09-30 08:24:50 -03:00
parent 41e5097c33
commit f3a372e78e
1 changed files with 2 additions and 2 deletions

View File

@ -1,5 +1,5 @@
// Aseprite // Aseprite
// Copyright (c) 2024 Igara Studio S.A. // Copyright (c) 2024-2025 Igara Studio S.A.
// //
// This program is distributed under the terms of // This program is distributed under the terms of
// the End-User License Agreement for Aseprite. // the End-User License Agreement for Aseprite.
@ -26,7 +26,7 @@ uint32_t convert_color_to_image(gfx::Color c, const os::SurfaceFormatData* fd)
uint8_t b = ((c & fd->blueMask) >> fd->blueShift); uint8_t b = ((c & fd->blueMask) >> fd->blueShift);
uint8_t a = ((c & fd->alphaMask) >> fd->alphaShift); uint8_t a = ((c & fd->alphaMask) >> fd->alphaShift);
if (fd->pixelAlpha == os::PixelAlpha::kPremultiplied) { if (a > 0 && fd->pixelAlpha == os::PixelAlpha::kPremultiplied) {
r = r * 255 / a; r = r * 255 / a;
g = g * 255 / a; g = g * 255 / a;
b = b * 255 / a; b = b * 255 / a;