ir_function_inlining: Avoid NULL dereference on assignment conditions.
authorEric Anholt <eric@anholt.net>
Fri, 23 Apr 2010 01:41:32 +0000 (18:41 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Fri, 23 Apr 2010 23:12:44 +0000 (16:12 -0700)
ir_function_inlining.cpp

index c0e77b427304875ca287a8a4700c3bae3963e9e5..025124ae2b205263d28e7759e6ade0b56f97d2e8 100644 (file)
@@ -214,7 +214,7 @@ ir_function_cloning_visitor::visit(ir_dereference *ir)
 void
 ir_function_cloning_visitor::visit(ir_assignment *ir)
 {
-   ir_rvalue *lhs, *rhs, *condition;
+   ir_rvalue *lhs, *rhs, *condition = NULL;
 
    ir->lhs->accept(this);
    lhs = this->result->as_rvalue();
@@ -222,8 +222,10 @@ ir_function_cloning_visitor::visit(ir_assignment *ir)
    ir->rhs->accept(this);
    rhs = this->result->as_rvalue();
 
-   ir->condition->accept(this);
-   condition = this->result->as_rvalue();
+   if (ir->condition) {
+      ir->condition->accept(this);
+      condition = this->result->as_rvalue();
+   }
 
    this->result = new ir_assignment(lhs, rhs, condition);
 }