From: Marcelina Koƛcielnicka Date: Mon, 13 Jun 2022 10:22:59 +0000 (+0200) Subject: opt_ffinv: Fix use after free. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=1ff0e1a58a350c03f59053a584d2e4b76a5a1b80;p=yosys.git opt_ffinv: Fix use after free. --- 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;