GHashTables are freed with g_hash_table_destroy() instead of g_hash_table_unref(). This could be a problem when dbus-glib passes a hash table to the user's code and the user calls g_hash_table_ref() to keep a reference. After dbus-glib has called g_hash_table_destroy() the user will get an emptied hash table. g_hash_table_unref() is available only since glib 2.10.
Created attachment 10472 [details] [review] Depend on glib 2.10
Created attachment 10473 [details] [review] Use g_hash_table_unref() instead of g_hash_table_destroy() in hash_table_simple_free() This change is backward compatible, nothing should happen because now you always need to copy the table so you don't care if dbus is using _destroy or _unref. The only difference would be in the case you are using _ref to get an empty hash table :) However, this change should be documented so, if you are depending on an older version of dbus-glib, you know that you should dup the hash table.
Created attachment 10474 [details] [review] Change every occurrence of g_hash_table_destroy() to g_hash_table_unref() Other occurrences of g_hash_table_destroy() should not be a problem for users, but maybe it's a good idea to change them too.
I like the non-wholesale version; trying to be conservative with changes. We can revisit changing to _unref in other places if necessary later. I also modified the patch to use GLIB_CHECK_VERSION to allow compilation on older glibs. commit a8bf32ab8b0e30e0c74e07c58e9bc79a448683b2 Author: Colin Walters <walters@verbum.org> Date: Tue May 27 14:31:58 2008 -0400 Bug 11396: Use g_hash_table_unref if available (Marco Barisione) This lets users ref hashes with g_hash_table_ref.
Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.