Mesa (glsl2): glsl2: Don' t dereference a NULL var in CE handling during a compile error.

Eric Anholt anholt at kemper.freedesktop.org
Tue Jul 27 12:12:45 PDT 2010


Module: Mesa
Branch: glsl2
Commit: 54f583a206a15b1a92c547333adfae29ced796ef
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=54f583a206a15b1a92c547333adfae29ced796ef

Author: Eric Anholt <eric at anholt.net>
Date:   Tue Jul 27 12:10:50 2010 -0700

glsl2: Don't dereference a NULL var in CE handling during a compile error.

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 |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp
index f15530a..6a07f4e 100644
--- a/src/glsl/ir_constant_expression.cpp
+++ b/src/glsl/ir_constant_expression.cpp
@@ -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;
 }
 



More information about the mesa-commit mailing list