From 5c160d9fdf9d93307bcdfabef4a78eb7dc18694e Mon Sep 17 00:00:00 2001 From: Alex Blasche Date: Fri, 13 Apr 2018 17:00:19 +0200 Subject: BlueZ: Fix crash when discovering GATT service without readable items The jobs list might be empty and calling last() causes an assert in QVector. This implies the current process under discovery does not have any descriptors or characteristics which are readable. In such cases no async read requests have to be put forward and the discovery is already done. Change-Id: I8417bfcd146866cb16c295c9e9d4890270574a56 Reviewed-by: Oliver Wolff --- src/bluetooth/qlowenergycontroller_bluezdbus.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/bluetooth/qlowenergycontroller_bluezdbus.cpp b/src/bluetooth/qlowenergycontroller_bluezdbus.cpp index e9087642..afc4b8c1 100644 --- a/src/bluetooth/qlowenergycontroller_bluezdbus.cpp +++ b/src/bluetooth/qlowenergycontroller_bluezdbus.cpp @@ -537,8 +537,12 @@ void QLowEnergyControllerPrivateBluezDBus::discoverServiceDetails(const QBluetoo serviceData->endHandle = runningHandle++; // last job is last step of service discovery - GattJob &lastJob = jobs.last(); - lastJob.flags.setFlag(GattJob::LastServiceDiscovery, true); + if (!jobs.isEmpty()) { + GattJob &lastJob = jobs.last(); + lastJob.flags.setFlag(GattJob::LastServiceDiscovery, true); + } else { + serviceData->setState(QLowEnergyService::ServiceDiscovered); + } scheduleNextJob(); } -- cgit v1.2.3