OSDN Git Service

gateway: Fix D-Bus reply memory leak
authorSyam Sidhardhan <s.syam@samsung.com>
Thu, 12 Apr 2012 15:02:57 +0000 (20:32 +0530)
committerJohan Hedberg <johan.hedberg@intel.com>
Fri, 13 Apr 2012 09:38:16 +0000 (12:38 +0300)
Re-arrange the code to avoid the D-Bus memory leak. Earlier if rfcomm
is not connected, then there was a reply memory leak.

audio/gateway.c

index 19f8ce3..c549ef5 100644 (file)
@@ -598,13 +598,13 @@ static DBusMessage *ag_disconnect(DBusConnection *conn, DBusMessage *msg,
        if (!device->conn)
                return NULL;
 
+       if (!gw->rfcomm)
+               return btd_error_not_connected(msg);
+
        reply = dbus_message_new_method_return(msg);
        if (!reply)
                return NULL;
 
-       if (!gw->rfcomm)
-               return  btd_error_not_connected(msg);
-
        gateway_close(device);
        ba2str(&device->dst, gw_addr);
        DBG("Disconnected from %s, %s", gw_addr, device->path);