summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2018-11-21 18:13:53 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2018-11-21 10:29:15 -0800
commit01d031383c6b1568b2a0d1809ef83a742b10db8d (patch)
tree47c1bdba6176ab9a586d5ec0c0cb5785dbf4693a
parent5d8830750addc4bcf0f06d7ffa24012927143e59 (diff)
downloadsubsurface-01d031383c6b1568b2a0d1809ef83a742b10db8d.tar.gz
Core: fix crash concerning removal of dives from trips
Commit 6b283e598a3a08c6133d66b5d5617370296e7d0e replaced the linked list of dives in a trip by a table. Embarassingly, on dive deletion the index of the dive in the table was compared for "!= 0" instead of ">= 0". Thus, the first dive of a trip wouldn't be deleted, which ultimately led to a crash, as different parts of the code were now in disagreement over whether the trip is empty or not. Fix the comparison. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
-rw-r--r--core/divelist.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/core/divelist.c b/core/divelist.c
index 41036a65f..b10c4604b 100644
--- a/core/divelist.c
+++ b/core/divelist.c
@@ -872,7 +872,7 @@ struct dive_trip *unregister_dive_from_trip(struct dive *dive, short was_autogen
return NULL;
idx = get_idx_in_table(&trip->dives, dive);
- if (idx)
+ if (idx >= 0)
unregister_dive_from_table(&trip->dives, idx);
dive->divetrip = NULL;
return trip;