dbus_message_get_args memory allocation in old versions
John (J5) Palmieri
johnp at redhat.com
Sun Apr 24 15:36:30 PDT 2005
On Sun, 2005-04-24 at 16:47, Tony Houghton wrote:
> I'm updating ROX-Session to work with dbus 0.3x and found that it was
> calling g_free on a string returned by dbus_message_get_args. This is
> definitely wrong with dbus 0.3x, as the docs show, and it was crashing.
> But it had been working without apparent symptoms with 0.2x, whose docs
> don't mention where the memory comes from.
In 0.3x get_args just returns a pointer into the message however dbus
0.2x returns copies of strings that you need to free.
> I want to keep backwards
> compatibility for now, and if it was supposed to be freed in 0.2x I'll
> create a memory leak by not freeing it. So can anyone tell me whether it
> was ever right to free the string? I tried looking at the source, but
> got a bit lost in the marshalling stuff. Even if it should be freed, I
> think using g_free was technically wrong anyway and it should really be
> dbus_free.
Backwards compatibility is a hard goal with a pre 1.0 library. With
NetworkManager we finally decided to just do a fork. However there are
some people who are trying to keep both versions in the same source and
just switching with an autoconf check. If your use of DBus isn't that
extensive this is an option though I think going forward has the
potential to get confusing and cause bugs. BTW it is expected that the
0.3x series will be close to the final API for 1.0.
--
J5
> --
> TH * http://www.realh.co.uk
More information about the dbus
mailing list