Today, the HW website was down, resulting in a segfault when importing data from an OSTC3 or SPORT divecomputer, and selecting ok after the dives where (correctly) imported. It was caused by the check logic to see if a firmware upgrade was available.

This patch makes the check just a little more robust, and silently ignores a possible update of the firmware.

And includes 2 fixes typo's in the comments

Signed-off-by: Jan Mulder <[email protected]>

---
 desktop-widgets/configuredivecomputerdialog.cpp | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

[PATCH] Do not segfault when Heinrichs Weikamp website is offline

Today, the HW website was down, resulting in a segfault when importing
data from an OSTC3 or SPORT divecomputer, and selecting ok after the dives
where (correctly) imported. It was caused by the check logic to see if a
firmware upgrade was available.

This patch makes the check just a little more robust, and silently ignores
a possible update of the firmware.

And includes 2 fixes typo's in the comment

Signed-off-by: Jan Mulder <[email protected]>
---
 desktop-widgets/configuredivecomputerdialog.cpp | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/desktop-widgets/configuredivecomputerdialog.cpp b/desktop-widgets/configuredivecomputerdialog.cpp
index 79cdcaf..b54a913 100644
--- a/desktop-widgets/configuredivecomputerdialog.cpp
+++ b/desktop-widgets/configuredivecomputerdialog.cpp
@@ -254,7 +254,8 @@ void OstcFirmwareCheck::checkLatest(QWidget *_parent, device_data_t *data)
 {
 	devData = *data;
 	parent = _parent;
-	// If we didn't find a current firmware version stop this hole thing here.
+
+	// If we didn't find a current firmware version stop this whole thing here.
 	if (latestFirmwareAvailable.isEmpty())
 		return;
 
@@ -263,8 +264,14 @@ void OstcFirmwareCheck::checkLatest(QWidget *_parent, device_data_t *data)
 	int firmwareOnDevice = devData.libdc_firmware;
 	QString firmwareOnDeviceString = QString("%1.%2").arg(firmwareOnDevice / 256).arg(firmwareOnDevice % 256);
 
-	// Convert the latestFirmwareAvailable to a integear we can compare with
+	// Convert the latestFirmwareAvailable to a integer we can compare with
 	QStringList fwParts = latestFirmwareAvailable.split(".");
+
+	// Be a little carefull here. For example, when the HW website is down or changed, do not
+	// just continue processing but silently ignore the update check. Better than just segfaulting
+	// on invalid index
+	if (fwParts.length() != 2)
+		return;
 	int latestFirmwareAvailableNumber = fwParts[0].toInt() * 256 + fwParts[1].toInt();
 	if (latestFirmwareAvailableNumber > firmwareOnDevice) {
 		QMessageBox response(parent);
-- 
2.10.2
_______________________________________________
subsurface mailing list
[email protected]
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface

Reply via email to