fix 3 potential (small) memory leaks

This commit is contained in:
Stefan Frederik 2021-12-08 00:38:19 +01:00
parent 9f99a31fac
commit fa25edabec
4 changed files with 10 additions and 4 deletions

View File

@ -2836,6 +2836,6 @@ int tclvareval(const char *script, ...)
}
return_code = Tcl_EvalEx(interp, str, size, TCL_EVAL_GLOBAL);
va_end(args);
my_free(1381, &p);
my_free(1381, &str);
return return_code;
}

View File

@ -1632,7 +1632,7 @@ int print_spice_element(FILE *fd, int inst)
tok_val_len = strlen(value);
if(!strcmp(token, "@spiceprefix")) {
spiceprefixtag = my_malloc(301, tok_val_len+22);
my_realloc(301, &spiceprefixtag, tok_val_len+22);
my_snprintf(spiceprefixtag, tok_val_len+22, "**** spice_prefix %s\n", value);
value = spiceprefixtag;
}

View File

@ -1915,7 +1915,13 @@ int Tcl_AppInit(Tcl_Interp *inter)
/* source tcl file given on command line with --script */
if(tcl_script[0]) {
tclvareval("update; source {", tcl_script, "}", NULL);
char str[PATH_MAX + 40];
/* can not use tclvareval() here because if script contains 'exit'
* program terminates before tclvareval() has a chance to cleanup
* its dynamically allocated string
*/
my_snprintf(str, S(str), "update; source {%s}", tcl_script);
Tcl_EvalEx(interp, str, -1, TCL_EVAL_GLOBAL);
}
if(quit) {

View File

@ -335,7 +335,7 @@ comment="
"
tclcommand="
set count 0
set duration 1000
set duration 300
xschem select instance p8 ;# CLEAR_
xschem select instance p9 ;# CLK
xschem logic_set 0 ;# reset pulse (active low)