summaryrefslogtreecommitdiffstats
path: root/dive.c
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2015-10-02 21:25:17 -0400
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-10-02 21:25:17 -0400
commit7cfd124f6704137d4c37d2318d33cef753a858e4 (patch)
tree627508de806f9a96b15a3501b348d1489ce8b28e /dive.c
parentae854ff82277c632fc3e10683780ab64d1a36cb2 (diff)
downloadsubsurface-7cfd124f6704137d4c37d2318d33cef753a858e4.tar.gz
Avoid negative array index
This case should be impossible to hit - but this seems better than assuming this can never happen. Coverity CID 1325458 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'dive.c')
-rw-r--r--dive.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/dive.c b/dive.c
index 4de181c70..fb9c4cec7 100644
--- a/dive.c
+++ b/dive.c
@@ -2906,9 +2906,9 @@ static int split_dive_at(struct dive *dive, int a, int b)
fixup_dive(d1);
fixup_dive(d2);
+ if ((i = get_divenr(dive)) < 0)
+ return 0;
-
- i = get_divenr(dive);
delete_single_dive(i);
add_single_dive(i, d1);