aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXiretza <xiretza@xiretza.xyz>2021-03-15 15:55:18 +0100
committerMarcelina Koƛcielnicka <mwk@0x04.net>2021-03-18 13:50:13 +0100
commit3aa10e90ba1d57e4d01c199396a52fbd1a66fa7e (patch)
tree89c3bae745c3f75a2d299cb137abab28ef6df357
parentf4298b057ae0939b83283c8c7431097e71a32b62 (diff)
downloadyosys-3aa10e90ba1d57e4d01c199396a52fbd1a66fa7e.tar.gz
yosys-3aa10e90ba1d57e4d01c199396a52fbd1a66fa7e.tar.bz2
yosys-3aa10e90ba1d57e4d01c199396a52fbd1a66fa7e.zip
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.
-rw-r--r--kernel/modtools.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/kernel/modtools.h b/kernel/modtools.h
index 29c510059..3af5367b1 100644
--- a/kernel/modtools.h
+++ b/kernel/modtools.h
@@ -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);