From 01d031383c6b1568b2a0d1809ef83a742b10db8d Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Wed, 21 Nov 2018 18:13:53 +0100 Subject: 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 --- core/divelist.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'core') 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; -- cgit v1.2.3-70-g09d2