Fix a segfault in dffinit when the value has too few bits
authorMarcus Comstedt <marcus@mc.pp.se>
Sun, 8 Nov 2015 18:16:56 +0000 (19:16 +0100)
committerMarcus Comstedt <marcus@mc.pp.se>
Sun, 8 Nov 2015 18:16:56 +0000 (19:16 +0100)
The code was already trying to add the required number of bits, but
fell one short of the mark.

passes/techmap/dffinit.cc

index 6a80f043b871454558ac5e924b6aea2b79bb8523..e0273f439de1897bac5e547a8105f54f64dff9c1 100644 (file)
@@ -100,7 +100,7 @@ struct DffinitPass : public Pass {
                                        for (int i = 0; i < GetSize(sig); i++) {
                                                if (init_bits.count(sig[i]) == 0)
                                                        continue;
-                                               while (GetSize(value.bits) < i)
+                                               while (GetSize(value.bits) <= i)
                                                        value.bits.push_back(State::S0);
                                                value.bits[i] = init_bits.at(sig[i]);
                                                cleanup_bits.insert(sig[i]);