[PATCH 3/5] Fix potential division by zero

Anton Lundin glance at acc.umu.se
Thu Jul 10 13:11:44 PDT 2014


Signed-off-by: Anton Lundin <glance at acc.umu.se>
---
 dive.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/dive.c b/dive.c
index 683fbb8..4cb9672 100644
--- a/dive.c
+++ b/dive.c
@@ -2369,6 +2369,9 @@ int average_depth(struct diveplan *dive)
 	int last_depth = 0;
 	struct divedatapoint *dp = dive->dp;
 
+	if (!dp)
+		return 0;
+
 	while (dp) {
 		if (dp->time) {
 			/* Ignore gas indication samples */
-- 
1.9.1



More information about the subsurface mailing list