From 7b163573e651ea18188130773a4e38fb92ecc25e Mon Sep 17 00:00:00 2001 From: Timothy Slater Date: Fri, 2 Sep 2022 15:27:05 -0500 Subject: [PATCH] PixelPaint: Ensure bitmap contains selected pixel before deleting This fixes a bug which shows up when a layer is offset and the selection range includes pixels that are outside the current layer bitmap rect. We would still try to delete that pixel from the bitmap since there was no contains() check. --- Userland/Applications/PixelPaint/Layer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Userland/Applications/PixelPaint/Layer.cpp b/Userland/Applications/PixelPaint/Layer.cpp index 90b8609a44..3c8bab3035 100644 --- a/Userland/Applications/PixelPaint/Layer.cpp +++ b/Userland/Applications/PixelPaint/Layer.cpp @@ -142,7 +142,7 @@ void Layer::erase_selection(Selection const& selection) for (int x = translated_to_layer_space.left(); x < translated_to_layer_space.left() + translated_to_layer_space.width(); ++x) { // Selection is still in pre-translated coordinates, account for this by adding the layer's relative location - if (selection.is_selected(x + location().x(), y + location().y())) { + if (content_bitmap().rect().contains(x, y) && selection.is_selected(x + location().x(), y + location().y())) { content_bitmap().set_pixel(x, y, Color::Transparent); } }