From 1ff0e1a58a350c03f59053a584d2e4b76a5a1b80 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marcelina=20Ko=C5=9Bcielnicka?= Date: Mon, 13 Jun 2022 12:22:59 +0200 Subject: [PATCH] opt_ffinv: Fix use after free. --- passes/opt/opt_ffinv.cc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/passes/opt/opt_ffinv.cc b/passes/opt/opt_ffinv.cc index fe5b59fa5..5d989dafd 100644 --- a/passes/opt/opt_ffinv.cc +++ b/passes/opt/opt_ffinv.cc @@ -201,10 +201,13 @@ struct OptFfInvWorker { log("Discovering LUTs.\n"); - for (Cell *cell : module->selected_cells()) { - if (!RTLIL::builtin_ff_cell_types().count(cell->type)) - continue; + std::vector ffs; + + for (Cell *cell : module->selected_cells()) + if (RTLIL::builtin_ff_cell_types().count(cell->type)) + ffs.push_back(cell); + for (Cell *cell : ffs) { FfData ff(&initvals, cell); if (ff.has_sr) continue; -- 2.30.2