From f4237bf843929e30a1ce2976a389b7193597c704 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Tue, 26 Dec 2017 14:25:57 -0800 Subject: Cleanup: prevent out of bounds read Don't access cylinder[MAX_CYLINDERS] Coverity CID 208324 Signed-off-by: Dirk Hohndel --- core/dive.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'core/dive.c') 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; -- cgit v1.2.3-70-g09d2