From 01ae4af13d36c89a73b77ba46b78e561f1beef85 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Thu, 3 Mar 2016 13:16:28 -0800 Subject: Don't access undefined dive When walking the dive table we need to stop before accessing the yet-to-be-added new dive. Signed-off-by: Dirk Hohndel --- subsurface-core/divelist.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'subsurface-core') diff --git a/subsurface-core/divelist.c b/subsurface-core/divelist.c index 7b10d5c99..1e9065d8b 100644 --- a/subsurface-core/divelist.c +++ b/subsurface-core/divelist.c @@ -794,7 +794,7 @@ void add_single_dive(int idx, struct dive *dive) if (idx < 0) { // convert an idx of -1 so we do insert-in-chronological-order idx = dive_table.nr - 1; - for (int i = 0; i < dive_table.nr; i++) { + for (int i = 0; i < dive_table.nr - 1; i++) { if (dive->when <= dive_table.dives[i]->when) { idx = i; break; -- cgit v1.2.3-70-g09d2