Re-arrange the code to avoid the D-Bus memory leak. Earlier if rfcomm
is not connected, then there was a reply memory leak.
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);