aboutsummaryrefslogtreecommitdiffstats
path: root/subsurface-core
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2016-03-03 13:16:28 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2016-03-03 14:29:29 -0800
commit01ae4af13d36c89a73b77ba46b78e561f1beef85 (patch)
tree32703b7f736617ce76191b8879059ce9b60a4df0 /subsurface-core
parentbf798390fa994106795717301e568edb6af71e09 (diff)
downloadsubsurface-01ae4af13d36c89a73b77ba46b78e561f1beef85.tar.gz
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 <dirk@hohndel.org>
Diffstat (limited to 'subsurface-core')
-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;