From 8c29d0e8129b1a01a1d06e9948b31a53d3fb3ac8 Mon Sep 17 00:00:00 2001 From: Stefan Schippers Date: Sat, 11 Nov 2023 20:03:20 +0100 Subject: [PATCH] fix error in capa-2.sym and missing check for null xctx->inst[].instname in get_pin_attr() --- src/move.c | 4 ++-- src/token.c | 6 +++--- xschem_library/devices/capa-2.sym | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/move.c b/src/move.c index 2ba48d19..9755860b 100644 --- a/src/move.c +++ b/src/move.c @@ -821,7 +821,7 @@ void copy_objects(int what) xctx->inst[xctx->instances].node=NULL; xctx->inst[xctx->instances].name=NULL; my_strdup2(_ALLOC_ID_, &xctx->inst[xctx->instances].name, xctx->inst[n].name); - my_strdup(_ALLOC_ID_, &xctx->inst[xctx->instances].prop_ptr, xctx->inst[n].prop_ptr); + my_strdup2(_ALLOC_ID_, &xctx->inst[xctx->instances].prop_ptr, xctx->inst[n].prop_ptr); my_strdup2(_ALLOC_ID_, &xctx->inst[xctx->instances].lab, xctx->inst[n].lab); xctx->inst[n].sel=0; xctx->inst[xctx->instances].embed = xctx->inst[n].embed; @@ -834,7 +834,7 @@ void copy_objects(int what) xctx->inst[xctx->instances].rot = (xctx->inst[xctx->instances].rot + ( (xctx->move_flip && (xctx->inst[xctx->instances].rot & 1) ) ? xctx->move_rot+2 : xctx->move_rot) ) & 0x3; xctx->inst[xctx->instances].flip = (xctx->move_flip? !xctx->inst[n].flip:xctx->inst[n].flip); - my_strdup(_ALLOC_ID_, &xctx->inst[xctx->instances].instname, xctx->inst[n].instname); + my_strdup2(_ALLOC_ID_, &xctx->inst[xctx->instances].instname, xctx->inst[n].instname); /* the newpropcnt argument is zero for the 1st call and used in */ /* new_prop_string() for cleaning some internal caches. */ if(!newpropcnt) hash_names(-1, XINSERT); diff --git a/src/token.c b/src/token.c index 98561095..9c4006ed 100644 --- a/src/token.c +++ b/src/token.c @@ -3379,15 +3379,15 @@ static char *get_pin_attr(const char *token, int inst, int s_pnetname) char *ss; int slot; char *tmpstr = NULL; - tmpstr = my_malloc(_ALLOC_ID_, sizeof(xctx->inst[inst].instname)); - if( (ss=strchr(xctx->inst[inst].instname, ':')) ) { + if( xctx->inst[inst].instname && (ss=strchr(xctx->inst[inst].instname, ':')) ) { + tmpstr = my_malloc(_ALLOC_ID_, sizeof(xctx->inst[inst].instname)); sscanf(ss+1, "%s", tmpstr); if(isonlydigit(tmpstr)) { slot = atoi(tmpstr); if(strstr(value,":")) my_strdup2(_ALLOC_ID_, &value, find_nth(value, ":", "", 0, slot)); } + my_free(_ALLOC_ID_, &tmpstr); } - my_free(_ALLOC_ID_, &tmpstr); } my_free(_ALLOC_ID_, &pin_attr_value); my_free(_ALLOC_ID_, &pin_attr_value); diff --git a/xschem_library/devices/capa-2.sym b/xschem_library/devices/capa-2.sym index 56cffe6e..25e02cf9 100644 --- a/xschem_library/devices/capa-2.sym +++ b/xschem_library/devices/capa-2.sym @@ -1,4 +1,4 @@ -v {xschem version=3.4.4 file_version=1.2 +v {xschem version=3.4.5 file_version=1.2 * * This file is part of XSCHEM, * a schematic capture and Spice/Vhdl/Verilog netlisting tool for circuit @@ -31,7 +31,7 @@ template="name=C1 m=1 value=1p footprint=1206 -device=polarized_capacitor +device=polarized_capacitor" } V {} S {}