diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2013-11-08 21:40:59 +0900 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2013-11-08 21:40:59 +0900 |
commit | edecb0fcf904bb8d5901094b2e96079da644694d (patch) | |
tree | 080cd8532ec74339192cf0f7b9e5b02d3ca49d15 /planner.c | |
parent | 8941e8677e2b56084c07ac840adb1b655d5c806b (diff) | |
download | subsurface-edecb0fcf904bb8d5901094b2e96079da644694d.tar.gz |
Don't access invalid elements with depth = 0
This is a corner case in the planner that was exposed by the recent
changes to the way the dive plan reflects the gases during the dive.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'planner.c')
-rw-r--r-- | planner.c | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -616,7 +616,8 @@ void plan(struct diveplan *diveplan, char **cached_datap, struct dive **divep, b for (stopidx = 0; stopidx < sizeof(decostoplevels) / sizeof(int); stopidx++) if (decostoplevels[stopidx] >= depth) break; - stopidx--; + if (stopidx > 0) + stopidx--; /* so now we know the first decostop level above us * NOTE, this could be the surface or a long list of potential stops |