diff options
author | Rico Tzschichholz <ricotz@ubuntu.com> | 2017-05-17 09:09:13 +0200 |
---|---|---|
committer | Rico Tzschichholz <ricotz@ubuntu.com> | 2017-05-17 09:12:35 +0200 |
commit | d259b5f92c21c1137e5eadbc13ebe894a5df197d (patch) | |
tree | 62e10b24e199b921cc259e9939e10dccb4fb1cfc /codegen/valagvariantmodule.vala | |
parent | 076e669191cb7a8e62cd5fdba9e615708cc31bfe (diff) | |
download | vala-d259b5f92c21c1137e5eadbc13ebe894a5df197d.tar.gz |
gdbus: Don't leak nested HashTable on deserialization
Additionally make sure types derived from string are freed, e.g. ObjectPath
https://bugzilla.gnome.org/show_bug.cgi?id=782719
Diffstat (limited to 'codegen/valagvariantmodule.vala')
-rw-r--r-- | codegen/valagvariantmodule.vala | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/codegen/valagvariantmodule.vala b/codegen/valagvariantmodule.vala index b50aca02c..b3ff1cf51 100644 --- a/codegen/valagvariantmodule.vala +++ b/codegen/valagvariantmodule.vala @@ -394,7 +394,7 @@ public class Vala.GVariantModule : GAsyncModule { ccode.add_declaration ("GVariant*", new CCodeVariableDeclarator (value_name)); var hash_table_new = new CCodeFunctionCall (new CCodeIdentifier ("g_hash_table_new_full")); - if (key_type.data_type == string_type.data_type) { + if (key_type.data_type.is_subtype_of (string_type.data_type)) { hash_table_new.add_argument (new CCodeIdentifier ("g_str_hash")); hash_table_new.add_argument (new CCodeIdentifier ("g_str_equal")); } else if (key_type.data_type == gvariant_type) { @@ -405,18 +405,22 @@ public class Vala.GVariantModule : GAsyncModule { hash_table_new.add_argument (new CCodeIdentifier ("g_direct_equal")); } - if (key_type.data_type == string_type.data_type) { + if (key_type.data_type.is_subtype_of (string_type.data_type)) { hash_table_new.add_argument (new CCodeIdentifier ("g_free")); } else if (key_type.data_type == gvariant_type) { hash_table_new.add_argument (new CCodeCastExpression (new CCodeIdentifier ("g_variant_unref"), "GDestroyNotify")); + } else if (key_type.data_type.get_full_name () == "GLib.HashTable") { + hash_table_new.add_argument (new CCodeCastExpression (new CCodeIdentifier ("g_hash_table_unref"), "GDestroyNotify")); } else { hash_table_new.add_argument (new CCodeIdentifier ("NULL")); } - if (value_type.data_type == string_type.data_type) { + if (value_type.data_type.is_subtype_of (string_type.data_type)) { hash_table_new.add_argument (new CCodeIdentifier ("g_free")); } else if (value_type.data_type == gvariant_type) { hash_table_new.add_argument (new CCodeCastExpression (new CCodeIdentifier ("g_variant_unref"), "GDestroyNotify")); + } else if (value_type.data_type.get_full_name () == "GLib.HashTable") { + hash_table_new.add_argument (new CCodeCastExpression (new CCodeIdentifier ("g_hash_table_unref"), "GDestroyNotify")); } else { hash_table_new.add_argument (new CCodeIdentifier ("NULL")); } |