]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
codegen: Fix memory leak in set accessor with owned value
authorLuca Bruno <lucabru@src.gnome.org>
Thu, 9 Jun 2011 11:11:21 +0000 (13:11 +0200)
committerLuca Bruno <lucabru@src.gnome.org>
Thu, 9 Jun 2011 11:14:35 +0000 (13:14 +0200)
Fixes bug 652181.

codegen/valaccodebasemodule.vala

index 4ffca728b45c6209050b9793f9e4c0113cbe9bdc..5deaf959d2726b70b7697f0dd494e32460779c98 100644 (file)
@@ -1947,6 +1947,11 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
                                        return_out_parameter (param);
                                }
                        }
+               } else if (b.parent_symbol is PropertyAccessor) {
+                       var acc = (PropertyAccessor) b.parent_symbol;
+                       if (acc.value_parameter != null && !acc.value_parameter.captured && requires_destroy (acc.value_parameter.variable_type)) {
+                               ccode.add_expression (destroy_parameter (acc.value_parameter));
+                       }
                }
 
                if (b.captured) {
@@ -3109,6 +3114,11 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
                        append_local_free (sym.parent_symbol, stop_at_loop, stop_at);
                } else if (sym.parent_symbol is Method) {
                        append_param_free ((Method) sym.parent_symbol);
+               } else if (sym.parent_symbol is PropertyAccessor) {
+                       var acc = (PropertyAccessor) sym.parent_symbol;
+                       if (acc.value_parameter != null && requires_destroy (acc.value_parameter.variable_type)) {
+                               ccode.add_expression (destroy_parameter (acc.value_parameter));
+                       }
                }
        }