From: Clifford Wolf Date: Tue, 16 Aug 2016 07:07:13 +0000 (+0200) Subject: Fixed use-after-free dict<> usage pattern in hierarchy.cc X-Git-Tag: yosys-0.7~137 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=00f29d5e5cdd08a14aa02119f46f8ee10cd1368d;p=yosys.git Fixed use-after-free dict<> usage pattern in hierarchy.cc --- diff --git a/passes/hierarchy/hierarchy.cc b/passes/hierarchy/hierarchy.cc index 92fcb7d40..4bb765e75 100644 --- a/passes/hierarchy/hierarchy.cc +++ b/passes/hierarchy/hierarchy.cc @@ -322,10 +322,12 @@ bool set_keep_assert(std::map &cache, RTLIL::Module *mod) int find_top_mod_score(Design *design, Module *module, dict &db) { if (db.count(module) == 0) { + int score = 0; db[module] = 0; for (auto cell : module->cells()) if (design->module(cell->type)) - db[module] = max(db[module], find_top_mod_score(design, design->module(cell->type), db) + 1); + score = max(score, find_top_mod_score(design, design->module(cell->type), db) + 1); + db[module] = score; } return db.at(module); }