Fixed AstNode::mkconst_bits() segfault on zero-sized constant
authorClifford Wolf <clifford@clifford.at>
Thu, 24 Sep 2015 09:21:20 +0000 (11:21 +0200)
committerClifford Wolf <clifford@clifford.at>
Thu, 24 Sep 2015 09:21:20 +0000 (11:21 +0200)
frontends/ast/ast.cc

index a4585915736c84f23b0f08a83d04861b01a2fe2a..5044eeabcbb1b70aa6e05d78a37e959d99e86904 100644 (file)
@@ -699,7 +699,7 @@ AstNode *AstNode::mkconst_bits(const std::vector<RTLIL::State> &v, bool is_signe
        for (size_t i = 0; i < 32; i++) {
                if (i < node->bits.size())
                        node->integer |= (node->bits[i] == RTLIL::S1) << i;
-               else if (is_signed)
+               else if (is_signed && !node->bits.empty())
                        node->integer |= (node->bits.back() == RTLIL::S1) << i;
        }
        node->range_valid = true;