From 4eec911d3aa8060c495d35488ff0dcbf2eaa24b3 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Tue, 15 Jul 2014 03:14:15 -0700 Subject: [PATCH] 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 --- dive.c | 6 ++++-- 1 file 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()