From 19225039b8667679c175e62f1faa29495b4ed547 Mon Sep 17 00:00:00 2001 From: Nathan Lee <2431820-nathanal@users.noreply.gitlab.com> Date: Fri, 26 Apr 2019 00:30:04 +1000 Subject: Add out of bound checks to fill bucket Fixes https://gitlab.com/inkscape/inbox/issues/398 --- src/ui/tools/flood-tool.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/ui/tools/flood-tool.cpp') diff --git a/src/ui/tools/flood-tool.cpp b/src/ui/tools/flood-tool.cpp index 6db530917..68987dfcc 100644 --- a/src/ui/tools/flood-tool.cpp +++ b/src/ui/tools/flood-tool.cpp @@ -627,7 +627,7 @@ static ScanlineCheckResult perform_bitmap_scanline_check(std::deque bool can_paint_top = (top_ty > 0); bool can_paint_bottom = (bottom_ty < bci.height); - Geom::Point t = fill_queue->front(); + Geom::Point front_of_queue = fill_queue->empty() ? Geom::Point() : fill_queue->front(); do { ok = false; @@ -645,8 +645,11 @@ static ScanlineCheckResult perform_bitmap_scanline_check(std::deque paint_directions = paint_pixel(px, trace_px, orig_color, bci, current_trace_t); if (bci.radius == 0) { mark_pixel_checked(current_trace_t); - if ((t[Geom::X] == bci.x) && (t[Geom::Y] == bci.y)) { - fill_queue->pop_front(); t = fill_queue->front(); + if ((!fill_queue->empty()) && + (front_of_queue[Geom::X] == bci.x) && + (front_of_queue[Geom::Y] == bci.y)) { + fill_queue->pop_front(); + front_of_queue = fill_queue->empty() ? Geom::Point() : fill_queue->front(); } } -- cgit v1.2.3