summaryrefslogtreecommitdiffstats
path: root/dive.c
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2014-07-15 03:14:15 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-07-15 03:14:15 -0700
commit4eec911d3aa8060c495d35488ff0dcbf2eaa24b3 (patch)
tree457f0eca328ef4e3b61f8bcedad2e21cf4a0bf6d /dive.c
parent95dbfc22ac7508494cc5bc383b7fe804bef3a4e6 (diff)
downloadsubsurface-4eec911d3aa8060c495d35488ff0dcbf2eaa24b3.tar.gz
Planner: even with broken plans, don't divide by 0
This fixes the crash in #623, but not the other oddities. See #623 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'dive.c')
-rw-r--r--dive.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/dive.c b/dive.c
index e228ecb20..b303f2399 100644
--- a/dive.c
+++ b/dive.c
@@ -2404,8 +2404,10 @@ int average_depth(struct diveplan *dive)
}
dp = dp->next;
}
-
- return integral / last_time;
+ if (last_time)
+ return integral / last_time;
+ else
+ return 0;
}
struct picture *alloc_picture()