Skip to content

Commit

Permalink
Properly check if fill position is in bounds
Browse files Browse the repository at this point in the history
This may lead to a crash, no results at all or weird behavior if clicked
outside of a non-axis-aligned rectangle selection. Now it checks if the
point is in bounds and inside the selection properly.
  • Loading branch information
askmeaboutlo0m committed Nov 1, 2024
1 parent 15faad8 commit c05aaad
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/drawdance/libengine/dpengine/flood_fill.c
Original file line number Diff line number Diff line change
Expand Up @@ -1188,7 +1188,13 @@ DP_flood_fill(DP_CanvasState *cs, unsigned int context_id, int selection_id,
init_selection(&c.parent, cs, context_id, selection_id);

if (x < 0 || y < 0 || x >= c.parent.width || y >= c.parent.height
|| DP_rect_empty(c.parent.area)) {
|| DP_rect_empty(c.parent.area)
|| !DP_rect_contains(c.parent.area, x, y)
|| (c.parent.sel
&& DP_layer_content_pixel_at(
DP_selection_content_noinc(c.parent.sel), x, y)
.a
== 0)) {
DP_error_set("Flood fill: initial point out of bounds");
return DP_FLOOD_FILL_OUT_OF_BOUNDS;
}
Expand Down

0 comments on commit c05aaad

Please sign in to comment.