From d67ca376b2111717de88596888f315fba05ef9c3 Mon Sep 17 00:00:00 2001 From: Alex Blasche Date: Tue, 7 May 2019 16:04:59 +0200 Subject: BlueZ: Fix leaking client socket when running QLEController Peripheral mode In fact there are two socket leaks. The first is the socket for the incoming l2cp connection from the central device and the second one is allocated in the ctor of QBluetoothSocket. When QBluetoothSocket::setSocketDescriptor is called the previously ctor allocated socket was simply ignorred. This patch closes both socket. Fixes: QTBUG-75278 Change-Id: Ia483e3c2a04bec3a53ddf744c22b794941edf848 Reviewed-by: Timur Pocheptsov Reviewed-by: Oliver Wolff --- src/bluetooth/qbluetoothsocket_bluez.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/bluetooth/qbluetoothsocket_bluez.cpp') diff --git a/src/bluetooth/qbluetoothsocket_bluez.cpp b/src/bluetooth/qbluetoothsocket_bluez.cpp index bbc32a90..25f07bb3 100644 --- a/src/bluetooth/qbluetoothsocket_bluez.cpp +++ b/src/bluetooth/qbluetoothsocket_bluez.cpp @@ -674,6 +674,9 @@ bool QBluetoothSocketPrivateBluez::setSocketDescriptor(int socketDescriptor, QBl connectWriteNotifier = nullptr; socketType = socketType_; + if (socket != -1) + QT_CLOSE(socket); + socket = socketDescriptor; // ensure that O_NONBLOCK is set on new connections. -- cgit v1.2.3