From 6f2639aee05d7108abcec03ed3dec3511c5c7112 Mon Sep 17 00:00:00 2001 From: Ryszard Rozak Date: Wed, 11 Feb 2026 12:47:16 +0100 Subject: [PATCH] Remove memory leak Signed-off-by: Ryszard Rozak --- src/V3Force.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/V3Force.cpp b/src/V3Force.cpp index a681a0b2e..707c92920 100644 --- a/src/V3Force.cpp +++ b/src/V3Force.cpp @@ -100,7 +100,6 @@ public: std::vector 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()};