OSDN Git Service

Fix regression when there is no agent registered.
authorLuiz Augusto von Dentz <luiz.dentz@openbossa.org>
Tue, 16 Jun 2009 20:26:27 +0000 (17:26 -0300)
committerJohan Hedberg <johan.hedberg@nokia.com>
Tue, 16 Jun 2009 20:52:10 +0000 (23:52 +0300)
The regression was introduced by audio_device_request_authorization which
cause the authorization request to be added the list no matter what
btd_request_authorization returns.

audio/device.c

index 4ef9c3f..78d2d0b 100644 (file)
@@ -680,6 +680,7 @@ int audio_device_request_authorization(struct audio_device *dev,
 {
        struct dev_priv *priv = dev->priv;
        struct service_auth *auth;
+       int err;
 
        auth = g_try_new0(struct service_auth, 1);
        if (!auth)
@@ -692,6 +693,12 @@ int audio_device_request_authorization(struct audio_device *dev,
        if (g_slist_length(priv->auths) > 1)
                return 0;
 
-       return btd_request_authorization(&dev->src, &dev->dst, uuid, auth_cb,
+       err = btd_request_authorization(&dev->src, &dev->dst, uuid, auth_cb,
                                        dev);
+       if (err < 0) {
+               priv->auths = g_slist_remove(priv->auths, auth);
+               g_free(auth);
+       }
+
+       return err;
 }