From 00f29d5e5cdd08a14aa02119f46f8ee10cd1368d Mon Sep 17 00:00:00 2001 From: Clifford Wolf Date: Tue, 16 Aug 2016 09:07:13 +0200 Subject: [PATCH] Fixed use-after-free dict<> usage pattern in hierarchy.cc --- passes/hierarchy/hierarchy.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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); } -- 2.30.2