Fixed memory corruption in subcircuit miner
authorClifford Wolf <clifford@clifford.at>
Sun, 3 Mar 2013 12:33:02 +0000 (13:33 +0100)
committerClifford Wolf <clifford@clifford.at>
Sun, 3 Mar 2013 12:33:02 +0000 (13:33 +0100)
libs/subcircuit/subcircuit.cc

index 2c6f3d827d8faf0b18976b048deef81c8a33edf7..0138d5a0f2015bf083eb4e5f7223e40fc72f08ad 100644 (file)
@@ -68,8 +68,10 @@ SubCircuit::Graph::Graph(const Graph &other, const std::vector<std::string> &oth
        for (auto &i1 : other2this)
        for (auto &i2 : other.nodes[i1.first].ports)
        for (auto &i3 : i2.bits)
-               if (edges2this.count(i3.edgeIdx) == 0)
-                       edges2this[i3.edgeIdx] = edges2this.size();
+               if (edges2this.count(i3.edgeIdx) == 0) {
+                       int next_idx = edges2this.size();
+                       edges2this[i3.edgeIdx] = next_idx;
+               }
 
        edges.resize(edges2this.size());
        for (auto &it : edges2this) {