RIF: org.freedesktop.DBus.GLib.ReturnVal frees returns value
frederic.heem at telsey.it
Fri Sep 15 11:06:37 PDT 2006
Dbus freeing the return value has at least 2 problems:
* If the application returns a static buffer, the application will crash when dbus frees the static buffer.
* The malloc/free mismatch: the application could use its own allocation mechanism and the free function that dbus uses cannot know how to deallocate the memory. This is a common problem with plugin based application.
If dbus really wants to free the return value, first it has to be clearly documented, then it has to provide an api to set the delete function to use when deleting the memory, an application would have to tell dbus which delete function to use.
Da: Havoc Pennington [mailto:hp at redhat.com]
Inviato: ven 15/09/2006 18.41
A: Frederic Heem
Cc: dbus at lists.freedesktop.org
Oggetto: Re: org.freedesktop.DBus.GLib.ReturnVal frees returns value
frederic heem wrote:
> sniffer_get allocates the string, stores it as the key value in a hash table
> and return the pointer to the string. Valgrind found that dbus is freeing the
> return value ?
> Dbus must not free memory an application has allocated because there could be
> a mismatch malloc/free between the application and libdbus.
If the return value were not freed, then the application would always
have to keep it around indefinitely, even if it was some on-the-fly
created string with no reason to store it.
If it's copied, then there's an abstraction barrier where the app is
welcome to store it or create it on the fly. This is the standard
glib/gtk API convention used in most of glib/gtk unless the returned
string is in some way inherently already stored.
Just add a g_strdup().
--- NOTICE ---
CONFIDENTIALITY - This email and any attachments are confidential and are
intended for the addressee only. If you have received this message by
mistake, please contact us immediately and then delete the message from your
system. You must not copy, distribute, disclose or act upon the contents of
this email. Thank you.
PERSONAL DATA PROTECTION (Law by Decree 30. 06.2003 n. 196) - Personal and
corporate data submitted will be used in a correct, transparent and lawful
manner. The data collected will be processed in paper or computerized form for
the performance of contractual and lawful obligations as well as for the
effective management of business relationship. Data may be disclosed, in Italy
or abroad, for the purpose above mentioned to third parties which cooperate
with Telsey, agents, banks, factoring companies, credit recovering companies,
credit insurance companies, professional and consultants, and shipping
companies. In relation to the same purposes, data may be processed by the
following classes of executors or processors: management; administration
department; logistics and purchase department; sales department; post sales
department quality department; R&D department; IT department; legal department.
The data processor is Telsey S.p.A. The data subject may exercise all the
rights set forth in art. 7 of Law by Decree 30. 06.2003 n. 196 as reported in
in the following link http://www.telsey.it/privacy.jsp.
More information about the dbus