From fa81e9d0077f1dd2732dc1fa6d811377bf5bed30 Mon Sep 17 00:00:00 2001 From: rlar Date: Tue, 14 Aug 2012 20:22:13 +0200 Subject: [PATCH] plug a memory leak when (un)setting variables --- src/frontend/variable.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/frontend/variable.c b/src/frontend/variable.c index f853a7003..081a8f3ea 100644 --- a/src/frontend/variable.c +++ b/src/frontend/variable.c @@ -104,6 +104,14 @@ cp_vset(char *varname, enum cp_types type, void *value) } w = v; } + + if (alreadythere) { + if(v->va_type == CP_LIST) + free_struct_variable(v->va_vlist); + if(v->va_type == CP_STRING) + tfree(v->va_string); + } + if (!v) { v = alloc(struct variable); v->va_name = copy(copyvarname); @@ -536,8 +544,9 @@ cp_remvar(char *varname) break; } + v->va_next = NULL; tfree(v->va_name); - tfree(v); + free_struct_variable(v); free_struct_variable(uv1); }