glsl2: Don't dereference a NULL var in CE handling during a compile error.
authorEric Anholt <eric@anholt.net>
Tue, 27 Jul 2010 19:10:50 +0000 (12:10 -0700)
committerEric Anholt <eric@anholt.net>
Tue, 27 Jul 2010 19:10:50 +0000 (12:10 -0700)
If an undeclared variable was dereferenced in an expression that
needed constant expression handling, we would walk off a null ir->var
pointer.

Fixes:
glsl1-TIntermediate::addUnaryMath

src/glsl/ir_constant_expression.cpp

index f15530ae89e40e6cd8744d4d38363e45aa795013..6a07f4e18954ed300c5c938eb61efb0d46b6f07b 100644 (file)
@@ -676,6 +676,10 @@ ir_swizzle::constant_expression_value()
 ir_constant *
 ir_dereference_variable::constant_expression_value()
 {
+   /* This may occur during compile and var->type is glsl_type::error_type */
+   if (!var)
+      return NULL;
+
    return var->constant_value ? var->constant_value->clone(NULL) : NULL;
 }