Skip to content
  • Cosimo Cecchi's avatar
    gapplication: don't rely on cmdline being finalized immediately · c5748328
    Cosimo Cecchi authored and Matthias Clasen's avatar Matthias Clasen committed
    The GApplicationCommandLine DBus implementation currently calls
    g_dbus_method_invocation_return_value() in its finalize() implementation
    only, relying on the object being destroyed after g_object_unref() is
    called on it inside g_application_impl_method_call().
    
    While this is usually fine for C applications, when overriding the
    command_line vfunc from language bindings, the binding might add extra
    references to the object, which might not be released immediately - e.g.
    because they're garbage collected, or possibly even leaked. The same
    scenario could happen in a C application that decides to keep a
    reference to the passed-in GApplicationCommandLine object.
    
    To ensure the CommandLine DBus method always gets a reply after the
    invocation of command_line in the primary instance, explicitly send the
    message back before dropping our reference to the object.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=708042
    c5748328