glsl: Fix lower_named_interface_blocks to account for dereferences of consts.
authorPaul Berry <stereotype441@gmail.com>
Sun, 14 Jul 2013 15:57:49 +0000 (08:57 -0700)
committerPaul Berry <stereotype441@gmail.com>
Mon, 15 Jul 2013 14:59:52 +0000 (07:59 -0700)
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.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
src/glsl/lower_named_interface_blocks.cpp

index 922cc024f897156ba7efed97034eb127ebda431b..d0d491d3db170d66ca3938f0de0245954255c4fb 100644 (file)
@@ -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;