diff options
author | Clifford Wolf <clifford@clifford.at> | 2016-08-16 09:07:13 +0200 |
---|---|---|
committer | Clifford Wolf <clifford@clifford.at> | 2016-08-16 09:07:13 +0200 |
commit | 00f29d5e5cdd08a14aa02119f46f8ee10cd1368d (patch) | |
tree | bde70041370d272a88354ad792edc0a511ce187c | |
parent | b4d544f0d90d50059d95520d863924bffa3122ac (diff) | |
download | yosys-00f29d5e5cdd08a14aa02119f46f8ee10cd1368d.tar.gz yosys-00f29d5e5cdd08a14aa02119f46f8ee10cd1368d.tar.bz2 yosys-00f29d5e5cdd08a14aa02119f46f8ee10cd1368d.zip |
Fixed use-after-free dict<> usage pattern in hierarchy.cc
-rw-r--r-- | passes/hierarchy/hierarchy.cc | 4 |
1 files changed, 3 insertions, 1 deletions
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<RTLIL::Module*, bool> &cache, RTLIL::Module *mod) int find_top_mod_score(Design *design, Module *module, dict<Module*, int> &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); } |