mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
Don't crash if add_gas_switch_event() gets called with invalid index
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
136282f88a
commit
216fa8d543
1 changed files with 3 additions and 0 deletions
|
@ -750,6 +750,9 @@ static void try_to_match_autogroup(const char *name, char *buf)
|
|||
|
||||
void add_gas_switch_event(struct dive *dive, struct divecomputer *dc, int seconds, int idx)
|
||||
{
|
||||
/* sanity check so we don't crash */
|
||||
if (idx < 0 || idx >= MAX_CYLINDERS)
|
||||
return;
|
||||
/* The gas switch event format is insane for historical reasons */
|
||||
struct gasmix *mix = &dive->cylinder[idx].gasmix;
|
||||
int o2 = get_o2(mix);
|
||||
|
|
Loading…
Reference in a new issue