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 <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41447>
This commit is contained in:
Tanner Van De Walle 2026-05-08 15:36:12 -07:00 committed by Marge Bot
parent e2cd37e422
commit 427158f784

View file

@ -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);