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>
This commit is contained in:
Dirk Hohndel 2013-11-08 21:40:59 +09:00
parent 8941e8677e
commit edecb0fcf9

View file

@ -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