From 281865fde4591c28b23afb006841ca6ece736b74 Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Sat, 16 Aug 2025 08:13:53 -0700 Subject: modules/flow/flow: fix edge case segfault When flow became threaded this bug was introduced. It's possible for the unchecked put_pixel to go out of bounds while stepping through n_iters, since the bounds check bypassing this doesn't consider the full range of the iterated coordinates. A simple fix to prevent the segfault is to use the checked variant. --- src/modules/flow/flow.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/modules') diff --git a/src/modules/flow/flow.c b/src/modules/flow/flow.c index c9b94e4..901eda8 100644 --- a/src/modules/flow/flow.c +++ b/src/modules/flow/flow.c @@ -295,6 +295,8 @@ static void flow_render_fragment(til_module_context_t *context, til_stream_t *st /* for cases obviously outside the fragment, don't draw anything */ + /* FIXME: these early-outs don't consider the ctxt->n_iters interpolated coordinates */ + /* totally outside (above) */ if (y1 < fy1 && y2 < fy1) continue; @@ -331,7 +333,8 @@ static void flow_render_fragment(til_module_context_t *context, til_stream_t *st x1 = pos.x / (pos.z + ZCONST) * ffw + (ffw >> 1); y1 = pos.y / (pos.z + ZCONST) * ffh + (ffh >> 1); - (void) til_fb_fragment_put_pixel_unchecked(fragment, TIL_FB_DRAW_FLAG_TEXTURABLE, x1, y1, pixel); + /* XXX: now that [xy]1 are changed, unchecked can't be used, it could be done more cleverly */ + (void) til_fb_fragment_put_pixel_checked(fragment, TIL_FB_DRAW_FLAG_TEXTURABLE, x1, y1, pixel); } continue; -- cgit v1.2.3