summaryrefslogtreecommitdiff
path: root/codegen/valaccodestructmodule.vala
diff options
context:
space:
mode:
authorRico Tzschichholz <ricotz@ubuntu.com>2021-02-04 10:55:31 +0100
committerRico Tzschichholz <ricotz@ubuntu.com>2021-02-04 10:55:31 +0100
commit1383402ee5e0c20f1374f12488e1c73a5aafc81b (patch)
tree7ef60312c478d67c408df23c0eaed2d4c0781c3a /codegen/valaccodestructmodule.vala
parent63551acaf0d83fac8b50904c2759c1098fbfaa71 (diff)
downloadvala-1383402ee5e0c20f1374f12488e1c73a5aafc81b.tar.gz
codegen: Chain up to base struct destroy function
Found by -fsanitize=address
Diffstat (limited to 'codegen/valaccodestructmodule.vala')
-rw-r--r--codegen/valaccodestructmodule.vala14
1 files changed, 14 insertions, 0 deletions
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);
}
}