dbus_g_bus_get return value

Olivier Andrieu oliv__a at users.sourceforge.net
Tue Oct 5 10:17:12 PDT 2004

 > Leonardo Boiko [Tue, 05 Oct 2004]:
 > Thank you for the help, but I understood the reason for the failure. 
 > I'm sorry if I wasn't clear.  My issue is not with the function 
 > returning an error, it is with the sample tutorial code not detecting 
 > this error.
 > If you check for "error != NULL", when there is no session bus, the 
 > program will print an error message and abort.  However, it checks for 
 > "connection == NULL", which fails because dbus_g_bus_get returned 
 > garbage, and the program tries to use the invalid connection.

The problem really is that dbus_g_bus_get should return NULL and not garbage.

The convention for these functions is that the return value is NULL if
and only an error is set. Here it is not because of the pointer
mangling thing that ought to be skipped when connection is NULL.


More information about the dbus mailing list