[vala/0.50] codegen: Chain up to base struct destroy function



commit fcbf4d996a7b63692c021fafeea7383b68e5fe40
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Thu Feb 4 10:55:31 2021 +0100

    codegen: Chain up to base struct destroy function
    
    Found by -fsanitize=address

 codegen/valaccodestructmodule.vala | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
---
diff --git a/codegen/valaccodestructmodule.vala b/codegen/valaccodestructmodule.vala
index 9a492d485..2eab9e0e1 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);
        }
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]