[Mesa-dev] [PATCH] glsl: Fix lower_named_interface_blocks to account for dereferences of consts.

Paul Berry stereotype441 at gmail.com
Sun Jul 14 09:27:12 PDT 2013


In certain rare cases (such as those involving dereference of a
literal constant array of structs),
flatten_named_interface_blocks_declarations's rvalue visitor may be
invoked on an ir_dereference_record whose variable_referenced() method
returns NULL.

Check for this case to avoid a segfault.

Prevents crashes in piglit tests
{vs,fs}-deref-literal-array-of-structs.
---
 src/glsl/lower_named_interface_blocks.cpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/glsl/lower_named_interface_blocks.cpp b/src/glsl/lower_named_interface_blocks.cpp
index 922cc02..d0d491d 100644
--- a/src/glsl/lower_named_interface_blocks.cpp
+++ b/src/glsl/lower_named_interface_blocks.cpp
@@ -194,6 +194,8 @@ flatten_named_interface_blocks_declarations::handle_rvalue(ir_rvalue **rvalue)
       return;
 
    ir_variable *var = ir->variable_referenced();
+   if (var == NULL)
+      return;
 
    if (!var->is_interface_instance())
       return;
-- 
1.8.3.2



More information about the mesa-dev mailing list