GNOME Bugzilla – Bug 770335
gdbus-codegen: generated getter for 'ao' property is actually (transfer container)
Last modified: 2018-02-06 16:00:41 UTC
In ./gio/tests/gdbus-test-codegen-generated.c we have: /** * foo_igen_bar_get_ao: (skip) * @object: A #FooiGenBar. * * (...) * * Returns: (transfer none): The property value or %NULL if the property is not set. Do not free the returned value, it belongs to @object. */ const gchar *const * foo_igen_bar_get_ao (FooiGenBar *object) { return FOO_IGEN_BAR_GET_IFACE (object)->get_ao (object); } which is implemented in proxy using: static const gchar *const * foo_igen_bar_proxy_get_ao (FooiGenBar *object) { FooiGenBarProxy *proxy = FOO_IGEN_BAR_PROXY (object); GVariant *variant; const gchar *const *value = NULL; variant = g_dbus_proxy_get_cached_property (G_DBUS_PROXY (proxy), "ao"); if (variant != NULL) { value = g_variant_get_objv (variant, NULL); g_variant_unref (variant); } return value; } But g_variant_get_objv() is actually (transfer container), and so is foo_igen_bar_get_ao(). This leaks to array leaks in the code using this generated API.
Created attachment 366952 [details] [review] codegen: Fix a typo in g_variant_get_objv() g_variant_get_objpathv() doesn’t exist. The code actually meant g_variant_get_objv(). This fixes a leak with `ao`-type properties in generated code. Previously they wouldn’t be freed; now the container is (correctly) freed. Signed-off-by: Philip Withnall <withnall@endlessm.com>
Fixed. Review welcome. Newly generated code: static const gchar *const * foo_igen_bar_proxy_get_ao (FooiGenBar *object) { FooiGenBarProxy *proxy = FOO_IGEN_BAR_PROXY (object); GVariant *variant; const gchar *const *value = NULL; value = g_datalist_get_data (&proxy->priv->qdata, "ao"); if (value != NULL) return value; variant = g_dbus_proxy_get_cached_property (G_DBUS_PROXY (proxy), "ao"); if (variant != NULL) { value = g_variant_get_objv (variant, NULL); g_datalist_set_data_full (&proxy->priv->qdata, "ao", (gpointer) value, g_free); g_variant_unref (variant); } return value; }
Review of attachment 366952 [details] [review]: :thumbsup:
Pushed to master, thanks. Attachment 366952 [details] pushed as 567e554 - codegen: Fix a typo in g_variant_get_objv()