From e7b8e89d2fe4eed1d51ee6a66a3d818c2095b024 Mon Sep 17 00:00:00 2001 From: "R. Timothy Edwards" Date: Wed, 24 Jun 2026 13:51:40 -0400 Subject: [PATCH] Added a few lines to ResMerge.c which avoid a crash condition when a resistor subnet has been linked to itself (or something like that). Otherwise it leads to a double-free and a crash. This commit does not address why the subnet was linked to itself, and the crash was preceded by another internal diagnostic message "Missing rptr at ..." which has been noted before but still needs to be tracked down and fixed. It is likely that a bad output netlist was created, but at least magic doesn't segfault. --- resis/ResMerge.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/resis/ResMerge.c b/resis/ResMerge.c index e201a102..79463d89 100644 --- a/resis/ResMerge.c +++ b/resis/ResMerge.c @@ -260,7 +260,19 @@ ResSeriesCheck(resptr) if (rr2->rr_connection1 == resptr) { resptr2 = rr1->rr_connection2; - if (rr1->rr_connection2 == rr2->rr_connection2) + if (rr1 == rr2) /* This should not happen, but does? */ + { + TxError("Internal error: Resistor linked to itself!\n"); + status = LOOP; + ResDeleteResPointer(rr2->rr_connection1, rr2); + ResDeleteResPointer(rr2->rr_connection2, rr2); + resptr2->rn_float.rn_area += rr2->rr_float.rr_area + + rr2->rr_float.rr_area + + resptr->rn_float.rn_area; + ResEliminateResistor(rr2, &ResResList); + ResCleanNode(resptr, TRUE, &ResNodeList, &ResNodeQueue); + } + else if (rr1->rr_connection2 == rr2->rr_connection2) { status = LOOP; ResDeleteResPointer(rr1->rr_connection1, rr1);