[Mesa-dev] [PATCH] nir: only dereference undef after NULL check.

Dave Airlie airlied at gmail.com
Sun Apr 17 20:56:41 UTC 2016


From: Dave Airlie <airlied at redhat.com>

Pointed out by coverity.

Signed-off-by: Dave Airlie <airlied at redhat.com>
---
 src/compiler/nir/nir_builder.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/compiler/nir/nir_builder.h b/src/compiler/nir/nir_builder.h
index 29b13fb..1425dba 100644
--- a/src/compiler/nir/nir_builder.h
+++ b/src/compiler/nir/nir_builder.h
@@ -79,10 +79,10 @@ nir_ssa_undef(nir_builder *build, unsigned num_components, unsigned bit_size)
 {
    nir_ssa_undef_instr *undef =
       nir_ssa_undef_instr_create(build->shader, num_components, bit_size);
-   undef->def.bit_size = bit_size;
    if (!undef)
       return NULL;
 
+   undef->def.bit_size = bit_size;
    nir_instr_insert(nir_before_cf_list(&build->impl->body), &undef->instr);
 
    return &undef->def;
-- 
2.5.5



More information about the mesa-dev mailing list