diff options
author | Sergio Ahumada <sahumada@blackberry.com> | 2015-02-09 12:15:23 +0100 |
---|---|---|
committer | Alex Blasche <alexander.blasche@theqtcompany.com> | 2015-02-10 08:15:11 +0000 |
commit | 76e0133d8cc627995d95847715527e79a33e5471 (patch) | |
tree | dbf3218c108c52dba8f933d9326667580bad4e70 /src/bluetooth/qbluetoothlocaldevice_bluez.cpp | |
parent | 8d3f8eabf5428de257c46dda10d541d0ce4b582a (diff) |
Avoid potential memory leak on variable 'device'
Change-Id: I4a3907dc1f8b8608b1c1b34e16d2e987cdc23be3
Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
Diffstat (limited to 'src/bluetooth/qbluetoothlocaldevice_bluez.cpp')
-rw-r--r-- | src/bluetooth/qbluetoothlocaldevice_bluez.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/bluetooth/qbluetoothlocaldevice_bluez.cpp b/src/bluetooth/qbluetoothlocaldevice_bluez.cpp index c7ee556d..0df7cc5d 100644 --- a/src/bluetooth/qbluetoothlocaldevice_bluez.cpp +++ b/src/bluetooth/qbluetoothlocaldevice_bluez.cpp @@ -345,6 +345,7 @@ void QBluetoothLocalDevice::requestPairing(const QBluetoothAddress &address, Pai QMetaObject::invokeMethod(this, "error", Qt::QueuedConnection, Q_ARG(QBluetoothLocalDevice::Error, QBluetoothLocalDevice::PairingError)); + delete device; return; } delete device; @@ -368,6 +369,7 @@ void QBluetoothLocalDevice::requestPairing(const QBluetoothAddress &address, Pai QMetaObject::invokeMethod(this, "error", Qt::QueuedConnection, Q_ARG(QBluetoothLocalDevice::Error, QBluetoothLocalDevice::PairingError)); + delete device; return; } delete device; @@ -579,15 +581,21 @@ QBluetoothLocalDevice::Pairing QBluetoothLocalDevice::pairingStatus( QDBusPendingReply<QVariantMap> deviceReply = device->GetProperties(); deviceReply.waitForFinished(); - if (deviceReply.isError()) + if (deviceReply.isError()) { + delete device; return Unpaired; + } QVariantMap map = deviceReply.value(); - if (map.value(QStringLiteral("Trusted")).toBool() && map.value(QStringLiteral("Paired")).toBool()) + if (map.value(QStringLiteral("Trusted")).toBool() && map.value(QStringLiteral("Paired")).toBool()) { + delete device; return AuthorizedPaired; - else if (map.value(QStringLiteral("Paired")).toBool()) + } else if (map.value(QStringLiteral("Paired")).toBool()) { + delete device; return Paired; + } + delete device; } else if (d_ptr->adapterBluez5) { QDBusPendingReply<ManagedObjectList> reply = d_ptr->managerBluez5->GetManagedObjects(); |