]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
codegen: Don't leak array memory after it was implicitly copied
authorRico Tzschichholz <ricotz@ubuntu.com>
Tue, 2 Feb 2021 09:34:54 +0000 (10:34 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Tue, 2 Feb 2021 09:39:47 +0000 (10:39 +0100)
Found by -fsanitize=address

codegen/valaccodebasemodule.vala

index 61e831ff9df8a998d404b4a3b6e5aa8180dbc1bb..cb45509428bf79056cbae2940666897ff85bc7c3 100644 (file)
@@ -6154,6 +6154,11 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
                                Report.error (node.source_reference, "missing class prerequisite for interface `%s', add GLib.Object to interface declaration if unsure", target_type.type_symbol.get_full_name ());
                                return result;
                        }
+                       // need to free old array after copying it
+                       if (array_needs_copy && requires_destroy (type)) {
+                               result.value_type = type.copy ();
+                               ccode.add_expression (destroy_value (result));
+                       }
                        result = copy;
 
                        // implicit array copying is deprecated, but allow it for internal codegen usage