aboutsummaryrefslogtreecommitdiffstats
path: root/parse-xml.c
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2015-04-20 23:22:48 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-04-20 23:28:51 -0700
commit216fa8d5439880785c2eaa7fccd29d9befa0280a (patch)
tree2c803b190e57680110a31131f464bb8408a6b8f5 /parse-xml.c
parent136282f88a28e11f6bfa26750a85b5f1e2bf8be3 (diff)
downloadsubsurface-216fa8d5439880785c2eaa7fccd29d9befa0280a.tar.gz
Don't crash if add_gas_switch_event() gets called with invalid index
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'parse-xml.c')
-rw-r--r--parse-xml.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/parse-xml.c b/parse-xml.c
index 0abcfcb0c..a02c4afac 100644
--- a/parse-xml.c
+++ b/parse-xml.c
@@ -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);