]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
codegen: Chain up to base struct destroy function
authorRico Tzschichholz <ricotz@ubuntu.com>
Thu, 4 Feb 2021 09:55:31 +0000 (10:55 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Thu, 4 Feb 2021 09:55:31 +0000 (10:55 +0100)
Found by -fsanitize=address

codegen/valaccodestructmodule.vala

index 585d460dbf3ac18282cdea0870de20770a2c00ab..5dfc8e8cbeb578399b004ce4378cc826619b5d69 100644 (file)
@@ -330,6 +330,20 @@ public abstract class Vala.CCodeStructModule : CCodeBaseModule {
        }
 
        void add_struct_destroy_function (Struct st) {
+               unowned Struct sym = st;
+               while (sym.base_struct != null) {
+                       sym = sym.base_struct;
+               }
+               if (st != sym) {
+                       push_context (instance_finalize_context);
+
+                       var destroy_func = new CCodeFunctionCall (new CCodeIdentifier (get_ccode_destroy_function (sym)));
+                       destroy_func.add_argument (new CCodeIdentifier ("self"));
+                       ccode.add_expression (destroy_func);
+
+                       pop_context ();
+               }
+
                cfile.add_function (instance_finalize_context.ccode);
        }
 }