From 427158f784cdc2a0aec8b0883e6273c406142d4b Mon Sep 17 00:00:00 2001 From: Tanner Van De Walle Date: Fri, 8 May 2026 15:36:12 -0700 Subject: [PATCH] draw: add lower-bound assert on shader_stage draw_set_sampler_views asserts shader_stage < DRAW_MAX_SHADER_STAGE but not >= 0. MSVC's prefast static analyzer reports C33010 (UNCHECKED_LOWER_BOUND_FOR_ENUMINDEX) when shader_stage is subsequently used as an array subscript, since it cannot prove the non-negative side of the bound. Extending the existing assert to both sides silences the warning and is a real bound check. Reviewed-by: Jesse Natalie Part-of: --- src/gallium/auxiliary/draw/draw_context.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/auxiliary/draw/draw_context.c b/src/gallium/auxiliary/draw/draw_context.c index 6bd9f58a1d1..10daaa25086 100644 --- a/src/gallium/auxiliary/draw/draw_context.c +++ b/src/gallium/auxiliary/draw/draw_context.c @@ -1055,7 +1055,7 @@ draw_set_sampler_views(struct draw_context *draw, struct pipe_sampler_view **views, unsigned num) { - assert(shader_stage < DRAW_MAX_SHADER_STAGE); + assert(shader_stage >= 0 && shader_stage < DRAW_MAX_SHADER_STAGE); assert(num <= PIPE_MAX_SHADER_SAMPLER_VIEWS); draw_do_flush(draw, DRAW_FLUSH_STATE_CHANGE);