From 69b485012faa67e14042b8f7f034a30086f5789b Mon Sep 17 00:00:00 2001 From: Yilou Wang Date: Sun, 1 Mar 2026 23:16:37 +0100 Subject: [PATCH] fix leak --- src/V3Randomize.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/V3Randomize.cpp b/src/V3Randomize.cpp index 25f13a704..d7333a1f1 100644 --- a/src/V3Randomize.cpp +++ b/src/V3Randomize.cpp @@ -3631,6 +3631,14 @@ class RandomizeVisitor final : public VNVisitor { constrExprp->replaceWith(chainp); VL_DO_DANGLING(constrExprp->deleteTree(), constrExprp); } + + // Clean up nodes used only as clone templates (never inserted into tree) + for (auto& bucket : buckets) { + VL_DO_DANGLING(bucket.weightExprp->deleteTree(), bucket.weightExprp); + } + VL_DO_DANGLING(runningSump->deleteTree(), runningSump); + // Last cumSum is unused (last bucket is unconditional default) + VL_DO_DANGLING(cumSums.back()->deleteTree(), cumSums.back()); } }