From af3982766e2dc7e245b2074ba03c5ceee601747c Mon Sep 17 00:00:00 2001 From: Tim Edwards Date: Thu, 24 Aug 2017 09:50:40 -0400 Subject: [PATCH] Prevented a crash condition in the error case in which ports are unordered at the time of reaching reorderpins(). Pins will be ordered arbitrarily (in the order of appearance in the linked list), but netgen will not crash. --- base/netcmp.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/base/netcmp.c b/base/netcmp.c index d34b952..13152a8 100644 --- a/base/netcmp.c +++ b/base/netcmp.c @@ -6057,7 +6057,7 @@ int reorderpins(struct hashlist *p, int file) struct nlist *ptr; struct nlist *tc2 = Circuit2; struct objlist *ob, *ob2, *firstpin; - int i, numports, *nodes; + int i, numports, *nodes, unordered; char **names; ptr = (struct nlist *)(p->ptr); @@ -6071,14 +6071,23 @@ int reorderpins(struct hashlist *p, int file) /* instances of both cells. */ numports = 0; + unordered = 0; ob2 = tc2->cell; while (ob2 && ob2->type == PORT) { + if (ob2->model.port < 0) { + ob2->model.port = numports; + unordered = 1; + } numports++; ob2 = ob2->next; } nodes = (int *)CALLOC(numports, sizeof(int)); names = (char **)CALLOC(numports, sizeof(char *)); + if (unordered) + Fprintf(stderr, "Ports of %s are unordered. " + "Ordering will be arbitrary.", tc2->name); + for (ob = ptr->cell; ob != NULL; ) { if (ob->type == FIRSTPIN) { if ((*matchfunc)(ob->model.class, tc2->name)) {