Remove memory leak

Signed-off-by: Ryszard Rozak <rrozak@antmicro.com>
This commit is contained in:
Ryszard Rozak 2026-02-11 12:47:16 +01:00
parent 34b170acb0
commit 6f2639aee0
1 changed files with 1 additions and 2 deletions

View File

@ -100,7 +100,6 @@ public:
std::vector<AstAssign*> assigns;
AstNodeStmt* const rdUpdateStmtsp = getAssignStmtsp(rdRefp, vscp, rdRefp, assigns);
AstVarRef* const enRefp = new AstVarRef{flp, m_enVscp, VAccess::WRITE};
AstNodeStmt* const enInitStmtsp = rdUpdateStmtsp->cloneTree(true);
for (size_t i = 0; i < assigns.size(); i++) {
// Save copies, because clonep() works only after the last cloneTree
@ -109,7 +108,7 @@ public:
for (AstAssign* const assignp : assigns) {
AstVarRef* const lhsVarRefp
= VN_AS(AstNodeVarRef::varRefLValueRecurse(assignp->lhsp()), VarRef);
lhsVarRefp->replaceWith(enRefp->cloneTree(false));
lhsVarRefp->replaceWith(new AstVarRef{flp, m_enVscp, VAccess::WRITE});
lhsVarRefp->deleteTree();
assignp->rhsp()->unlinkFrBack()->deleteTree();
V3Number zero{m_enVscp, assignp->lhsp()->dtypep()->width()};