summaryrefslogtreecommitdiffstats
path: root/subsurface-core/divelist.c
diff options
context:
space:
mode:
Diffstat (limited to 'subsurface-core/divelist.c')
-rw-r--r--subsurface-core/divelist.c2
1 files changed, 1 insertions, 1 deletions
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;