summaryrefslogtreecommitdiffstats
path: root/qt-ui
diff options
context:
space:
mode:
authorGravatar Robert C. Helling <helling@atdotde.de>2014-11-22 21:07:57 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-11-22 16:22:57 -0800
commit13934b0f02a812cc5073ab21f2cbee754ecaee14 (patch)
treecd8d9a1b08deb283f55e7d885261a0b92aae0795 /qt-ui
parent38bbed978a86d5b748ed61540632a25859cab7df (diff)
downloadsubsurface-13934b0f02a812cc5073ab21f2cbee754ecaee14.tar.gz
Check error code of get_cylider_idx_by_use()
If not cylinder with type DILUENT or OXYGEN is defined, this function returns -1 which should not be used as an index to an array. This patch adds code to check for this return value and exit gracefully. On line I marked with a comment. Someone more knowledgeable of that part of code than me should double check that return is here what we want. [Dirk Hohndel: fixed small oversight...] Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui')
-rw-r--r--qt-ui/profile/diveprofileitem.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/qt-ui/profile/diveprofileitem.cpp b/qt-ui/profile/diveprofileitem.cpp
index 038987fe7..8ee0f3494 100644
--- a/qt-ui/profile/diveprofileitem.cpp
+++ b/qt-ui/profile/diveprofileitem.cpp
@@ -618,7 +618,7 @@ void DiveGasPressureItem::modelDataChanged(const QModelIndex &topLeft, const QMo
for (int i = 0, count = dataModel->rowCount(); i < count; i++) {
entry = dataModel->data().entry + i;
mbar = GET_PRESSURE(entry);
- if (displayed_dive.dc.dctype == CCR)
+ if (displayed_dive.dc.dctype == CCR && displayed_dive.oxygen_cylinder_index >= 0)
o2mbar = GET_O2CYLINDER_PRESSURE(entry);
if (o2mbar) {