Module: Mesa
Branch: main
Commit: 91761006f62678e315a29157e4c7662b74fb115b
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=91761006f62678e315a29157e4c7662b74fb115b

Author: Corentin Noël <corentin.n...@collabora.com>
Date:   Mon Nov  6 14:19:53 2023 +0100

gallivm: Initialize indir_index to NULL before use

In the case `if (var)` is false, the value will still be used but uninitialized.

Signed-off-by: Corentin Noël <corentin.n...@collabora.com>
Reviewed-by: Erik Faye-Lund <erik.faye-l...@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26067>

---

 src/gallium/auxiliary/gallivm/lp_bld_nir.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/gallium/auxiliary/gallivm/lp_bld_nir.c 
b/src/gallium/auxiliary/gallivm/lp_bld_nir.c
index a753844f868..ded1e8317e5 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_nir.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_nir.c
@@ -1406,7 +1406,7 @@ visit_load_var(struct lp_build_nir_context *bld_base,
    assert(util_bitcount(deref->modes) == 1);
    nir_variable_mode mode = deref->modes;
    unsigned const_index = 0;
-   LLVMValueRef indir_index;
+   LLVMValueRef indir_index = NULL;
    LLVMValueRef indir_vertex_index = NULL;
    unsigned vertex_index = 0;
    unsigned nc = instr->def.num_components;
@@ -1458,7 +1458,7 @@ visit_store_var(struct lp_build_nir_context *bld_base,
    unsigned bit_size = nir_src_bit_size(instr->src[1]);
    LLVMValueRef src = get_src(bld_base, instr->src[1]);
    unsigned const_index = 0;
-   LLVMValueRef indir_index, indir_vertex_index = NULL;
+   LLVMValueRef indir_index = NULL, indir_vertex_index = NULL;
    if (var) {
       bool tcs_out = bld_base->shader->info.stage == MESA_SHADER_TESS_CTRL &&
          var->data.mode == nir_var_shader_out && !var->data.patch;

Reply via email to