From a22b7508acfe46593c6994847f213a39c4272f72 Mon Sep 17 00:00:00 2001 From: "R. Timothy Edwards" Date: Fri, 17 Jul 2026 13:39:51 -0400 Subject: [PATCH] Moved the freeMagic() of the labelList created for isolated substrate regions into extHardFreeAll(), where it is easy to detect if it has already been freed along with the rest of the labeled regions, to avoid a double free() call. --- extract/ExtHard.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/extract/ExtHard.c b/extract/ExtHard.c index d3877c85..af05e4ba 100644 --- a/extract/ExtHard.c +++ b/extract/ExtHard.c @@ -247,10 +247,8 @@ extHardProc(scx, arg) reg->treg_labels = NULL; } - if (subList != NULL) freeMagic(subList); - /* No luck; it's as though there was no geometry at all */ - extHardFreeAll(def, labRegList); + extHardFreeAll(def, labRegList, subList); } /* No luck; check our subcells recursively */ @@ -259,8 +257,7 @@ extHardProc(scx, arg) goto done; success: - if (subList != NULL) freeMagic(subList); - extHardFreeAll(def, labRegList); + extHardFreeAll(def, labRegList, subList); ret = 1; done: @@ -480,13 +477,15 @@ extHardGenerateLabel(scx, reg, arg) */ void -extHardFreeAll(def, tReg) +extHardFreeAll(def, tReg, subList) CellDef *def; TransRegion *tReg; + LabelList *subList; { TransRegion *reg; LabelList *ll; FindRegion arg; + bool subFound = FALSE; /* Don't need to initialize arg.fra_first below */ arg.fra_connectsTo = ExtCurStyle->exts_nodeConn; @@ -512,10 +511,12 @@ extHardFreeAll(def, tReg) { if (ll->ll_label->lab_flags & LABEL_GENERATE) freeMagic(ll->ll_label); freeMagic1(&mm1_, (char *) ll); + if (ll == subList) subFound = TRUE; } freeMagic1_end(&mm1_); } freeMagic1(&mm1, (char *) reg); } freeMagic1_end(&mm1); + if (!subFound && (subList != NULL)) freeMagic(subList); }