From 7cfd124f6704137d4c37d2318d33cef753a858e4 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Fri, 2 Oct 2015 21:25:17 -0400 Subject: 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 --- dive.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'dive.c') 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); -- cgit v1.2.3-70-g09d2