summaryrefslogtreecommitdiffstats
path: root/core/dive.c
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2017-12-26 14:25:57 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2017-12-26 14:25:57 -0800
commitf4237bf843929e30a1ce2976a389b7193597c704 (patch)
tree0254831805dd1b375affaaa02e36659279e31585 /core/dive.c
parent1a46f5eb9bcee0f8b3fdee9fc6c4f1143b2663c0 (diff)
downloadsubsurface-f4237bf843929e30a1ce2976a389b7193597c704.tar.gz
Cleanup: prevent out of bounds read
Don't access cylinder[MAX_CYLINDERS] Coverity CID 208324 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'core/dive.c')
-rw-r--r--core/dive.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/core/dive.c b/core/dive.c
index 4b103bfbd..0a8c9f2a9 100644
--- a/core/dive.c
+++ b/core/dive.c
@@ -245,7 +245,7 @@ struct gasmix *get_gasmix_from_event(struct dive *dive, struct event *ev)
static struct gasmix dummy;
if (ev && event_is_gaschange(ev)) {
int index = ev->gas.index;
- if (index >= 0 && index <= MAX_CYLINDERS)
+ if (index >= 0 && index < MAX_CYLINDERS)
return &dive->cylinder[index].gasmix;
return &ev->gas.mix;
}
@@ -756,7 +756,7 @@ struct sample *prepare_sample(struct divecomputer *dc)
// Init some values with -1
sample->bearing.degrees = -1;
sample->ndl.seconds = -1;
-
+
return sample;
}
return NULL;