From: Rico Tzschichholz Date: Thu, 4 Feb 2021 09:55:31 +0000 (+0100) Subject: codegen: Chain up to base struct destroy function X-Git-Tag: 0.51.1~19 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1383402ee5e0c20f1374f12488e1c73a5aafc81b;p=thirdparty%2Fvala.git codegen: Chain up to base struct destroy function Found by -fsanitize=address --- diff --git a/codegen/valaccodestructmodule.vala b/codegen/valaccodestructmodule.vala index 585d460db..5dfc8e8cb 100644 --- a/codegen/valaccodestructmodule.vala +++ b/codegen/valaccodestructmodule.vala @@ -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); } }