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>
This commit is contained in:
Robert C. Helling 2014-11-22 21:07:57 +01:00 committed by Dirk Hohndel
parent 38bbed978a
commit 13934b0f02
3 changed files with 11 additions and 2 deletions

View file

@ -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) {