fix memleaks
authorMichael Wallner <mike@php.net>
Tue, 22 Dec 2015 14:58:59 +0000 (15:58 +0100)
committerMichael Wallner <mike@php.net>
Tue, 22 Dec 2015 14:58:59 +0000 (15:58 +0100)
src/context.c
src/parser.h

index ef9cc40490a209a26f7fb806efe5c6ade6066fd0..5b08426a96bfecf7692b14b0a482508f6b207615 100644 (file)
@@ -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)) {
index 796705db2a862c2b294fb864dd6ba217847cd7b0..660b35573f99ce89c8cafd75557c131275fc443d 100644 (file)
@@ -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);
 }