From: Michael Wallner Date: Tue, 22 Dec 2015 14:58:59 +0000 (+0100) Subject: fix memleaks X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=35914cd494aac5ca32868ed4e791ccef04d5216d;p=m6w6%2Fext-psi fix memleaks --- diff --git a/src/context.c b/src/context.c index ef9cc40..5b08426 100644 --- a/src/context.c +++ b/src/context.c @@ -699,9 +699,13 @@ static inline int validate_impl_let_stmts(PSI_Data *data, impl *impl) { /* e.g. let foo = *bar; */ let->var->pointer_level = let->val->data.var->pointer_level; let->var->arg = init_decl_arg( - init_decl_type(real_decl_type(let->val->data.var->arg->type)->type, + init_decl_type( + real_decl_type(let->val->data.var->arg->type)->type, real_decl_type(let->val->data.var->arg->type)->name), - init_decl_var(let->var->name, let->var->pointer_level, let->var->array_size)); + init_decl_var( + let->var->name, + let->var->pointer_level, + let->var->array_size)); break; case PSI_LET_NUMEXP: if (!validate_num_exp(data, impl->decl->args, impl->decl->func, let->val->data.num)) { diff --git a/src/parser.h b/src/parser.h index 796705d..660b355 100644 --- a/src/parser.h +++ b/src/parser.h @@ -716,10 +716,13 @@ static inline let_stmt *init_let_stmt(decl_var *var, let_val *val) { } static inline void free_let_stmt(let_stmt *stmt) { - free_decl_var(stmt->var); if (stmt->val) { + if (stmt->val->kind == PSI_LET_TMP && stmt->var->arg) { + free_decl_arg(stmt->var->arg); + } free_let_val(stmt->val); } + free_decl_var(stmt->var); free(stmt); } @@ -777,6 +780,9 @@ static inline void free_set_value(set_value *val) { } free(val->inner); } + if (val->num) { + free_num_exp(val->num); + } free(val); } @@ -832,6 +838,7 @@ static inline free_call *init_free_call(const char *func, decl_vars *vars) { static inline void free_free_call(free_call *f) { free(f->func); + free_decl_vars(f->vars); free(f); }