Fixed memory corruption with new SigSpec API in proc_mux
authorClifford Wolf <clifford@clifford.at>
Tue, 22 Jul 2014 20:54:39 +0000 (22:54 +0200)
committerClifford Wolf <clifford@clifford.at>
Tue, 22 Jul 2014 20:54:39 +0000 (22:54 +0200)
passes/proc/proc_mux.cc

index cd459d9495619411cba4fd5a6c9e19a8e2e3d98a..50ba8fa1e82f8ff50013e9fdd1d3e1a49b1c87ac 100644 (file)
@@ -68,20 +68,16 @@ static RTLIL::SigSpec gen_cmp(RTLIL::Module *mod, const RTLIL::SigSpec &signal,
        for (auto comp : compare)
        {
                RTLIL::SigSpec sig = signal;
-               sig.expand();
-               comp.expand();
 
                // get rid of don't-care bits
                assert(sig.size() == comp.size());
                for (int i = 0; i < comp.size(); i++)
-                       if (comp.chunks()[i].wire == NULL && comp.chunks()[i].data.bits[0] == RTLIL::State::Sa) {
-                               sig.remove(i, 1);
-                               comp.remove(i--, 1);
+                       if (comp[i] == RTLIL::State::Sa) {
+                               sig.remove(i);
+                               comp.remove(i--);
                        }
                if (comp.size() == 0)
                        return RTLIL::SigSpec();
-               sig.optimize();
-               comp.optimize();
 
                if (sig.size() == 1 && comp == RTLIL::SigSpec(1,1))
                {