From bd4e88ae3d2fa37f90a6c1b34091ce53209b81e1 Mon Sep 17 00:00:00 2001 From: Gavin Downard Date: Wed, 14 Jul 2021 16:43:11 -0700 Subject: [PATCH] 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. --- Userland/Applications/PixelPaint/Layer.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Userland/Applications/PixelPaint/Layer.cpp b/Userland/Applications/PixelPaint/Layer.cpp index a6d0d4be9e..29f5332bce 100644 --- a/Userland/Applications/PixelPaint/Layer.cpp +++ b/Userland/Applications/PixelPaint/Layer.cpp @@ -92,6 +92,9 @@ void Layer::set_name(String name) RefPtr 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());