summaryrefslogtreecommitdiff
path: root/codegen
diff options
context:
space:
mode:
authorRico Tzschichholz <ricotz@ubuntu.com>2017-05-17 09:09:13 +0200
committerRico Tzschichholz <ricotz@ubuntu.com>2017-06-08 12:15:29 +0200
commit63812b827a0628fac3a7c917d0df15e58b84b3c4 (patch)
tree351379edd421b226a0ebceea505aa2a434db4d19 /codegen
parentac4fc81fe84b3f5a0fa52159ba9bd89658ea18fa (diff)
downloadvala-63812b827a0628fac3a7c917d0df15e58b84b3c4.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')
-rw-r--r--codegen/valagvariantmodule.vala10
1 files changed, 7 insertions, 3 deletions
diff --git a/codegen/valagvariantmodule.vala b/codegen/valagvariantmodule.vala
index 409940eff..f3113f4f4 100644
--- a/codegen/valagvariantmodule.vala
+++ b/codegen/valagvariantmodule.vala
@@ -391,7 +391,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) {
@@ -402,18 +402,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"));
}