On Thu, May 6, 2010 at 5:50 PM, Enlightenment SVN
<[email protected]> wrote:
> Log:
>  e_dbus/hal: remove stringshare madness

Errr... I may be wrong, but I guess NOW it is wrong.


> @@ -31,8 +30,7 @@
>   switch(type)
>   {
>     case DBUS_TYPE_STRING:
> -      dbus_message_iter_get_basic(&iter, &tmp);
> -      ret->val.s = eina_stringshare_add(tmp);
> +      dbus_message_iter_get_basic(&iter, &(ret->val.s));
>       break;
>     case DBUS_TYPE_INT32:
>       dbus_message_iter_get_basic(&iter, &(ret->val.i));

what was wrong and mad about it?

http://dbus.freedesktop.org/doc/api/html/group__DBusMessage.html#g580376979e156abe06bbb3ccc3fc6d4c

dbus_message_iter_get_basic():
    "The returned value is by reference and should not be freed"

So clearly it is a reference to the DBus INTERNAL memory, and should
not be trusted after the message is gone, as it will depend on its
internal garbage collection and buffer management.

Having ret->val.s alive after the message iterator is changed is just
pure luck. You must add it to a stringshare or strdup() it, I'd rather
do the later.

If there was something else wrong with this code, fix it instead. This
commit is clearly wrong.


-- 
Gustavo Sverzut Barbieri
http://profusion.mobi embedded systems
--------------------------------------
MSN: [email protected]
Skype: gsbarbieri
Mobile: +55 (19) 9225-2202

------------------------------------------------------------------------------

_______________________________________________
enlightenment-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to