modtools: fix use-after-free of cell pointers in ModWalker

cell_inputs and cell_outputs retain cell pointers as their keys across
invocations of setup(), which may however be invalidated in the meantime
(as happens in e.g. passes/opt/share.cc:1432). A later rehash of the
dicts (caused by inserting in ModWalker::add_wire()) will cause them to
be dereferenced.
This commit is contained in:
Xiretza 2021-03-15 15:55:18 +01:00 committed by Marcelina Kościelnicka
parent f4298b057a
commit 3aa10e90ba
1 changed files with 2 additions and 0 deletions

View File

@ -395,6 +395,8 @@ struct ModWalker
signal_consumers.clear();
signal_inputs.clear();
signal_outputs.clear();
cell_inputs.clear();
cell_outputs.clear();
for (auto &it : module->wires_)
add_wire(it.second);