dbus_message_get_args memory allocation in old versions
Tony Houghton
h at realh.co.uk
Sun Apr 24 16:07:24 PDT 2005
In <1114382189.3257.19.camel at localhost.localdomain>, John (J5) Palmieri wrote:
> 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.
OK.
> > 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.
ROX-Session (before I started hacking it) managed to keep compatibility
without recompiling through 0.2x by using dlopen. I haven't managed that
with 0.3x because of the soname change, but it might be possible by
removing it altogether from the linker flags and looking up every
function we need with dlsym.
> BTW it is expected that the
> 0.3x series will be close to the final API for 1.0.
Good. But the python bindings are going to change quite a bit aren't
they?
--
TH * http://www.realh.co.uk
More information about the dbus
mailing list