After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 654394 - suspicious use of floating references in GDBusInterfaceSkeleton
suspicious use of floating references in GDBusInterfaceSkeleton
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: gdbus
unspecified
Other All
: Normal normal
: ---
Assigned To: David Zeuthen (not reading bugmail)
gtkdev
Depends on: 627974
Blocks:
 
 
Reported: 2011-07-11 13:38 UTC by Allison Karlitskaya (desrt)
Modified: 2011-07-12 17:46 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Allison Karlitskaya (desrt) 2011-07-11 13:38:46 UTC
/**
 * g_dbus_interface_skeleton_get_properties:
 * @interface_: A #GDBusInterfaceSkeleton.
 *
 * Gets all D-Bus properties for @interface_.
 *
 * Returns: A new, floating, #GVariant of type <link linkend="G-VARIANT-TYPE-VARDICT:CAPS">'a{sv}'</link>. Free with g_variant_unref().
 *
 * Since: 2.30
 */

This seems quite wrong.  Either a strong GVariant reference or no reference at all should be returned.  I imagine you probably want strong.

I advise calling g_variant_take_ref() on the return value before passing it on and documenting that the returned value is a normal reference.  That will allow implementations to return either strong or floating references from their vfunc and the caller to get a consistent experience.
Comment 1 David Zeuthen (not reading bugmail) 2011-07-11 14:21:02 UTC
I don't think there's anything wrong here (only gdbus-codegen(1) or similar will implement this and gdbus-codegen(1) gets it right)... but I'm not opposed to changing it if you supply a patch.
Comment 2 David Zeuthen (not reading bugmail) 2011-07-11 14:29:37 UTC
I'll fix this once the patch in bug 627974 lands. Thanks for your attention to detail!
Comment 3 Allison Karlitskaya (desrt) 2011-07-12 17:46:20 UTC
commit 8f5e0cd24016cdf852a809dfb7b1356328542201
Author: Ryan Lortie <desrt@desrt.ca>
Date:   Tue Jul 12 02:56:57 2011 +0200

    GDBusInterfaceSkeleton: fix odd use of floating refs
    
    The get_properties() function was documented as returning a floating
    
    Switch it over to returning a normal reference and patch a couple of
    uses.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=654394