Fixed two memory leaks in ast simplify
authorClifford Wolf <clifford@clifford.at>
Fri, 25 Jul 2014 11:07:31 +0000 (13:07 +0200)
committerClifford Wolf <clifford@clifford.at>
Fri, 25 Jul 2014 11:24:10 +0000 (13:24 +0200)
frontends/ast/simplify.cc

index d86bfb3f01e77029eb59013f8a1e25d1c0c6fa56..6302260a51c4370276004b91acf039fe2a3c1018 100644 (file)
@@ -895,7 +895,10 @@ bool AstNode::simplify(bool const_fold, bool at_zero, bool in_lvalue, int stage,
                                        log_error("Expression in generate case at %s:%d is not constant!\n", filename.c_str(), linenum);
                                }
 
-                               if (RTLIL::const_eq(ref_value, buf->bitsAsConst(), ref_signed && buf->is_signed, ref_signed && buf->is_signed, 1).as_bool()) {
+                               bool is_selected = RTLIL::const_eq(ref_value, buf->bitsAsConst(), ref_signed && buf->is_signed, ref_signed && buf->is_signed, 1).as_bool();
+                               delete buf;
+
+                               if (is_selected) {
                                        selected_case = this_genblock;
                                        i = children.size();
                                        break;
@@ -1301,6 +1304,8 @@ skip_dynamic_range_lvalue_expansion:;
                                        log_error("Failed to evaluate system function `%s' with non-constant value at %s:%d.\n", str.c_str(), filename.c_str(), linenum);
 
                                RTLIL::Const arg_value = buf->bitsAsConst();
+                               delete buf;
+
                                uint32_t result = 0;
                                for (size_t i = 0; i < arg_value.bits.size(); i++)
                                        if (arg_value.bits.at(i) == RTLIL::State::S1)