From e77ca25a80406e5e873fb8f3c8ba144446e11ed7 Mon Sep 17 00:00:00 2001 From: Leandro Ribeiro Date: Tue, 10 Jun 2025 20:52:12 -0300 Subject: [PATCH] color: fail weston_color_curve_to_3x1D_LUT() when !xform->steps_valid This is a leftover from "color: do not use color steps for non-optimized pipelines". If a xform don't have valid steps, it shouldn't have curves. So this function should fail. Signed-off-by: Leandro Ribeiro --- libweston/color.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/libweston/color.c b/libweston/color.c index 5b2a42331..9a7fc52d4 100644 --- a/libweston/color.c +++ b/libweston/color.c @@ -339,7 +339,8 @@ curve_to_lut_has_good_precision(struct weston_color_curve *curve) /** * Given a xform and an enum corresponding to one of its curves (pre or post), - * returns a 3x1D LUT that corresponds to such curve. + * returns a 3x1D LUT that corresponds to such curve. This only works for + * transformations such that xform->steps_valid. * * The 3x1D LUT returned looks like this: the first lut_size elements compose * the LUT for the R channel, the next lut_size elements compose the LUT for the @@ -382,6 +383,13 @@ weston_color_curve_to_3x1D_LUT(struct weston_compositor *compositor, weston_assert_not_reached(compositor, "unknown curve step"); } + if (!xform->steps_valid) { + str_printf(err_msg, "can't create LUT from xform (id %u) %s-curve, as the " \ + "xform don't have valid steps", + xform->id, step_str); + return NULL; + } + if (!curve_to_lut_has_good_precision(curve)) { if (precision_mode == WESTON_COLOR_PRECISION_CAREFUL) { str_printf(err_msg, "can't create color LUT from xform (id %u) " \