From 4381ac9a91101fbf73813fcc07391e515146b6a3 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Fri, 27 Feb 2026 09:03:26 -0800 Subject: [PATCH] intel/brw: Add assert for error case Coverity notices that there is an error case where `nir_get_io_data_src_number` could return `-1`, and that is then used to index into an array. Given that that is an exceptional case, we can just assert here. CID: 1681480 Part-of: --- src/intel/compiler/brw/brw_from_nir.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/intel/compiler/brw/brw_from_nir.cpp b/src/intel/compiler/brw/brw_from_nir.cpp index 751271022b6..37b1dc0cede 100644 --- a/src/intel/compiler/brw/brw_from_nir.cpp +++ b/src/intel/compiler/brw/brw_from_nir.cpp @@ -17,6 +17,7 @@ #include "util/lut.h" #include "compiler/glsl_types.h" +#include #include struct brw_bind_info { @@ -6002,8 +6003,14 @@ brw_from_nir_emit_memory_access(nir_to_brw_state &ntb, } int data_src = nir_get_io_data_src_number(instr); - unsigned components = is_store ? instr->src[data_src].ssa->num_components - : instr->def.num_components; + unsigned components; + if (is_store) { + assert(data_src >= 0); + components = instr->src[data_src].ssa->num_components; + } else { + components = instr->def.num_components; + } + if (components == 0) components = instr->num_components;