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
commit bd4e88ae3d
Notes: sideshowbarker 2024-07-18 08:58:51 +09:00

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());