_dbus_return_val_if_error_is_set (error, FALSE);
retval = FALSE;
+ message = NULL;
+ reply = NULL;
_DBUS_LOCK (bus_datas);
if (bd == NULL)
{
_DBUS_SET_OOM (error);
- _DBUS_UNLOCK (bus_datas);
- return FALSE;
+ goto out;
}
if (bd->unique_name != NULL)
{
_dbus_verbose ("Ignoring attempt to register the same DBusConnection %s with the message bus a second time.\n",
bd->unique_name);
- _DBUS_UNLOCK (bus_datas);
-
/* Success! */
- return TRUE;
+ retval = TRUE;
+ goto out;
}
message = dbus_message_new_method_call (DBUS_SERVICE_DBUS,
if (!message)
{
_DBUS_SET_OOM (error);
-
- _DBUS_UNLOCK (bus_datas);
- return FALSE;
+ goto out;
}
reply = dbus_connection_send_with_reply_and_block (connection, message, -1, error);
- dbus_message_unref (message);
-
if (reply == NULL)
goto out;
else if (dbus_set_error_from_message (error, reply))
retval = TRUE;
out:
+ _DBUS_UNLOCK (bus_datas);
+
+ if (message)
+ dbus_message_unref (message);
+
if (reply)
dbus_message_unref (reply);
if (!retval)
_DBUS_ASSERT_ERROR_IS_SET (error);
- _DBUS_UNLOCK (bus_datas);
-
return retval;
}