From adc4eb96c86787a362181c54efb239aef44bf5c8 Mon Sep 17 00:00:00 2001 From: Stefan Frederik Date: Tue, 30 Aug 2022 02:44:28 +0200 Subject: [PATCH] fix net_name() crashing if inst[i].node==NULL. This may happen when pasting a component that contains a @@xxx token, that needs to be expanded to attached netname, however since we are moving the component no net name is defined --> .node==NULL. --- src/scheduler.c | 1 + src/token.c | 9 ++++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/scheduler.c b/src/scheduler.c index c1db6dad..f78a9602 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -758,6 +758,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg cmd_found = 1; l = expandlabel(argv[2], &tmp); llen = strlen(l); + dbg(0, "l=%s\n", l ? l : ""); result = my_malloc(378, llen + 30); my_snprintf(result, llen + 30, "%s %d", l, tmp); Tcl_SetResult(interp, result, TCL_VOLATILE); diff --git a/src/token.c b/src/token.c index 3e94cfc9..6b296c58 100644 --- a/src/token.c +++ b/src/token.c @@ -2730,6 +2730,12 @@ const char *net_name(int i, int j, int *multip, int hash_prefix_unnamed_net, int char *pinname = NULL; + /* if merging a ngspice_probe.sym element it contains a @@p token, + * so translate calls net_name, but we are placing the merged objects, + * no net name is assigned yet */ + if(!xctx->inst[i].node) { + return expandlabel("", multip); + } if(xctx->inst[i].node && xctx->inst[i].node[j] == NULL) { my_strdup(1508, &pinname, get_tok_value( sym->rect[PINLAYER][j].prop_ptr,"name",0)); @@ -2744,9 +2750,6 @@ const char *net_name(int i, int j, int *multip, int hash_prefix_unnamed_net, int break; } } - } - if(xctx->inst[i].node && xctx->inst[i].node[j] == NULL) - { expandlabel(pinname, multip); if(pinname) my_free(1511, &pinname); if(erc) {