summaryrefslogtreecommitdiffstats
path: root/core/downloadfromdcthread.cpp
diff options
context:
space:
mode:
authorGravatar Robert C. Helling <helling@atdotde.de>2017-07-03 23:43:37 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2017-07-04 07:06:20 +0900
commitd17bb6318e17f85a243c6f618f9ed22b81ce4751 (patch)
tree2e069ef6609f6691b2b0dec22b29f719a694283c /core/downloadfromdcthread.cpp
parent8467e53f1178503de1d5bd5007e0361113d5f14b (diff)
downloadsubsurface-d17bb6318e17f85a243c6f618f9ed22b81ce4751.tar.gz
Don't try to dereference empty product/vendor list
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Diffstat (limited to 'core/downloadfromdcthread.cpp')
-rw-r--r--core/downloadfromdcthread.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/core/downloadfromdcthread.cpp b/core/downloadfromdcthread.cpp
index acb5ce6a8..ad4f0e4d0 100644
--- a/core/downloadfromdcthread.cpp
+++ b/core/downloadfromdcthread.cpp
@@ -378,6 +378,8 @@ QString DCDeviceData::getDeviceDescriptorVendor(const QString &currentVendorText
// unsure being a dive computer
if (currentVendorText == QObject::tr("Paired Bluetooth Devices")) {
int i = productList[currentVendorText].indexOf(currentProductText);
+ if (i < 0 || btAllDevices.length() <= i)
+ return QString();
QString dcVendor = dc_descriptor_get_vendor(btAllDevices[i].dcDescriptor);
qDebug() << "getDeviceDescriptorVendor" << dcVendor;
return dcVendor;
@@ -406,6 +408,8 @@ QString DCDeviceData::getDeviceDescriptorProduct(const QString &currentVendorTex
// unsure being a dive computer
if (currentVendorText == QObject::tr("Paired Bluetooth Devices")) {
int i = productList[currentVendorText].indexOf(currentProductText);
+ if (i >= btAllDevices.length() || i < 0)
+ return QString();
QString dcProduct = dc_descriptor_get_product(btAllDevices[i].dcDescriptor);
qDebug() << "getDeviceDescriptorProduct" << dcProduct;
return dcProduct;