glsl: Make sure not to dereference NULL
authorNeil Roberts <neil@linux.intel.com>
Sat, 4 Jul 2015 21:40:59 +0000 (22:40 +0100)
committerNeil Roberts <neil@linux.intel.com>
Mon, 6 Jul 2015 18:52:37 +0000 (11:52 -0700)
In this bit of code point_five can be NULL if the expression is not a
constant. This fixes it to match the pattern of the rest of the chunk
of code so that it checks for NULLs.

Cc: Matt Turner <mattst88@gmail.com>
Cc: "10.6" <mesa-stable@lists.freedesktop.org>
Reviewed-by: Matt Turner <mattst88@gmail.com>
src/glsl/opt_algebraic.cpp

index 9b8a426d79ccc5db4b284ab7978d581f45e42549..c4b871511990c4ab2ed1fa720fef8bcf311e23b1 100644 (file)
@@ -589,7 +589,7 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir)
                continue;
 
             ir_constant *point_five = add_expr->operands[1 - j]->as_constant();
-            if (!point_five->is_value(0.5, 0))
+            if (!point_five || !point_five->is_value(0.5, 0))
                continue;
 
             if (abs_expr->operands[0]->equals(sign_expr->operands[0])) {