diff --git a/src/frontend/options.c b/src/frontend/options.c index 8796cee4c..9969bbb7f 100644 --- a/src/frontend/options.c +++ b/src/frontend/options.c @@ -34,6 +34,9 @@ bool ft_ngdebug = FALSE, ft_stricterror = FALSE; * plot and circuit environment variables. */ +/* this is broken, returns sometimes "new" struct variable + * and sometimes already/still "used" struct variable (owned by someone else) + */ struct variable * cp_enqvar(char *word) { @@ -73,8 +76,9 @@ cp_enqvar(char *word) if (plot_cur) { for (vv = plot_cur->pl_env; vv; vv = vv->va_next) if (eq(vv->va_name, word)) - return (vv); + return (vv); /* <= return an already used struct variable */ if (eq(word, "curplotname")) + /* return a new allocaed struct variable */ return var_alloc_string(copy(word), copy(plot_cur->pl_name), NULL); if (eq(word, "curplottitle")) return var_alloc_string(copy(word), copy(plot_cur->pl_title), NULL); diff --git a/src/frontend/variable.c b/src/frontend/variable.c index bbc3f178c..2a87032d8 100644 --- a/src/frontend/variable.c +++ b/src/frontend/variable.c @@ -758,7 +758,7 @@ vareval(char *string) vfree = v = cp_enqvar(string); wl = wl_cons(copy(v ? "1" : "0"), NULL); tfree(oldstring); - free_struct_variable(vfree); + free_struct_variable(vfree); /* bug: free still used struct variable */ return (wl); case '#': @@ -780,7 +780,7 @@ vareval(char *string) i = (v->va_type != CP_BOOL); wl = wl_cons(tprintf("%d", i), NULL); tfree(oldstring); - free_struct_variable(vfree); + free_struct_variable(vfree); /* bug: free still used struct variable */ return (wl); case '\0': @@ -818,7 +818,7 @@ vareval(char *string) return (NULL); } wl = cp_varwl(v); - free_struct_variable(vfree); + free_struct_variable(vfree); /* bug: free still used struct variable */ /* Now parse and deal with 'range' ... */ if (range) {