Fix memory leaks - batch 2 (#6417)

This commit is contained in:
Geza Lore
2025-09-10 22:42:45 +01:00
committed by GitHub
parent 57d8bb5d1f
commit f1396fbced
13 changed files with 188 additions and 156 deletions
+3 -3
View File
@@ -1231,10 +1231,10 @@ class TaskVisitor final : public VNVisitor {
UASSERT_OBJ(!(nodep->dpiOpenParent() && nodep->dpiOpenChild()), nodep,
"DPI task should not be both parent and child");
dpiFuncp = getDpiFunc(nodep, rtnvarp);
if (!dpiFuncp) return nullptr; // There was an error, so bail
if (nodep->dpiImport() && nodep->dpiOpenParent()) {
if (!dpiFuncp || (nodep->dpiImport() && nodep->dpiOpenParent())) {
// No need to make more than just the DPI Import prototype, the children will
// create the wrapper implementations.
if (rtnvarp) VL_DO_DANGLING(pushDeletep(rtnvarp), rtnvarp);
VL_DO_DANGLING(pushDeletep(nodep), nodep);
return nullptr;
}
@@ -1355,7 +1355,7 @@ class TaskVisitor final : public VNVisitor {
for (AstNode *nextp, *stmtp = tempp->stmtsp(); stmtp; stmtp = nextp) {
nextp = stmtp->nextp();
if (AstVar* const portp = VN_CAST(stmtp, Var)) {
if (portp->isIO()) portp->unlinkFrBack();
if (portp->isIO()) VL_DO_DANGLING(pushDeletep(portp->unlinkFrBack()), portp);
}
}
if (tempp->stmtsp()) cfuncp->addStmtsp(tempp->stmtsp()->unlinkFrBackWithNext());