print_spice_subckt(): check for tcl_hook2() errors, check for NULL in strtoupper/strtolower, fix unitialized local variable

This commit is contained in:
Stefan Frederik 2022-08-23 10:01:32 +02:00
parent bd5cb7b9df
commit 0f5881cd61
3 changed files with 13 additions and 7 deletions

View File

@ -192,7 +192,7 @@ static int waves_callback(int event, int mx, int my, KeySym key, int button, int
double delta_threshold = 0.25;
double zoom_m = 0.5;
int save_mouse_at_end = 0, clear_graphpan_at_end = 0;
xRect *r;
xRect *r = NULL;
#if HAS_CAIRO==1
cairo_save(xctx->cairo_ctx);
cairo_save(xctx->cairo_save_ctx);
@ -333,7 +333,6 @@ static int waves_callback(int event, int mx, int my, KeySym key, int button, int
/* second loop: after having determined the master graph do the others */
for(i=0; i< xctx->rects[GRIDLAYER]; i++) {
xRect *r;
r = &xctx->rect[GRIDLAYER][i];
need_redraw = 0;
if( !(r->flags & 1) ) continue;

View File

@ -477,12 +477,12 @@ int my_strncpy(char *d, const char *s, size_t n)
char *strtolower(char* s) {
char *p;
for(p=s; *p; p++) *p=(char)tolower(*p);
if(s) for(p=s; *p; p++) *p=(char)tolower(*p);
return s;
}
char *strtoupper(char* s) {
char *p;
for(p=s; *p; p++) *p=(char)toupper(*p);
if(s) for(p=s; *p; p++) *p=(char)toupper(*p);
return s;
}

View File

@ -1653,11 +1653,18 @@ void print_spice_subckt(FILE *fd, int symbol)
size_t token_pos=0;
int escape=0;
int no_of_pins=0;
const char *tclres;
my_strdup(103, &format1, get_tok_value(xctx->sym[symbol].prop_ptr,"format",2));
dbg(1, "print_spice_subckt(): format1=%s\n", format1);
my_strdup(455, &format, tcl_hook2(&format1));
dbg(1, "print_spice_subckt(): format=%s\n", format);
dbg(0, "print_spice_subckt(): format1=%s\n", format1);
if(strstr(format1, "tcleval(") == format1) {
tclres = tcl_hook2(&format1);
if(!strcmp(tclres, "?\n")) my_strdup(1529, &format, format1 + 8);
else my_strdup(455, &format, tclres);
} else {
my_strdup(1530, &format, format1);
}
dbg(0, "print_spice_subckt(): format=%s\n", format);
if( format==NULL ) {
my_free(1012, &format);
return; /* no format */