dbus_g_method_get_sender duplicates memory given by dbus_message_get_sender
IMHO, it shouldn't duplicate anything, it should just returns a const gchar*
returned by dbus_message_get_sender.
This reduced the risk of memory leak from an application point of view. It is
Created attachment 7588 [details] [review]
Could you please explain why ?
Because that memory is freed as soon as the message is discarded, it breaks api,
and breaks exitig code.
Why dbus-glib imposes the burden of freeing the memory allocated by
Anyway, an application must not use the free function of pointer allocated by
a library. The library shall provide an API to free it itself.
Moreover, the memory is not freed when the message is discarded.
There is nowhere that dbus-glib could free this sensibly. Its standard glib
practice in such cases that the client code frees the memory (using g_free).
The memory returned by dbus_message_get_sender is a pointer to the string within
the message itself. In the core bindings its fine for dbus_message_get_sender to
return const char* as the user is managing the message lifetime herself, but in
dbus-glib the user should never have to worry about message lifetime (or indeed
messages) so hence the string duplication.
Fine, but please document the function that the returned pointer has to be
freed with g_free.
Agreed, renamed and reopened bug appropriately
Fixed in git head.