summaryrefslogtreecommitdiffstats
path: root/planner.c
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2013-11-08 21:40:59 +0900
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-11-08 21:40:59 +0900
commitedecb0fcf904bb8d5901094b2e96079da644694d (patch)
tree080cd8532ec74339192cf0f7b9e5b02d3ca49d15 /planner.c
parent8941e8677e2b56084c07ac840adb1b655d5c806b (diff)
downloadsubsurface-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.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/planner.c b/planner.c
index abefb6213..687da8273 100644
--- a/planner.c
+++ b/planner.c
@@ -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