mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Cleanup: prevent out of bounds read
Don't access cylinder[MAX_CYLINDERS] Coverity CID 208324 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
1a46f5eb9b
commit
f4237bf843
1 changed files with 2 additions and 2 deletions
|
@ -245,7 +245,7 @@ struct gasmix *get_gasmix_from_event(struct dive *dive, struct event *ev)
|
||||||
static struct gasmix dummy;
|
static struct gasmix dummy;
|
||||||
if (ev && event_is_gaschange(ev)) {
|
if (ev && event_is_gaschange(ev)) {
|
||||||
int index = ev->gas.index;
|
int index = ev->gas.index;
|
||||||
if (index >= 0 && index <= MAX_CYLINDERS)
|
if (index >= 0 && index < MAX_CYLINDERS)
|
||||||
return &dive->cylinder[index].gasmix;
|
return &dive->cylinder[index].gasmix;
|
||||||
return &ev->gas.mix;
|
return &ev->gas.mix;
|
||||||
}
|
}
|
||||||
|
@ -756,7 +756,7 @@ struct sample *prepare_sample(struct divecomputer *dc)
|
||||||
// Init some values with -1
|
// Init some values with -1
|
||||||
sample->bearing.degrees = -1;
|
sample->bearing.degrees = -1;
|
||||||
sample->ndl.seconds = -1;
|
sample->ndl.seconds = -1;
|
||||||
|
|
||||||
return sample;
|
return sample;
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue