1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 19:37:35 +00:00

PixelPaint: Fix crash when copying empty selection

Previously, trying to copy when there is no selection would crash,
trying to call mmap with a size of 0. Now it just leaves the clipboard
as it is.
This commit is contained in:
Gavin Downard 2021-07-14 16:43:11 -07:00 committed by Andreas Kling
parent 56cbd00e94
commit bd4e88ae3d

View file

@ -92,6 +92,9 @@ void Layer::set_name(String name)
RefPtr<Gfx::Bitmap> Layer::try_copy_bitmap(Selection const& selection) const
{
if (selection.is_empty()) {
return {};
}
auto selection_rect = selection.bounding_rect();
auto result = Gfx::Bitmap::create(Gfx::BitmapFormat::BGRA8888, selection_rect.size());