Core: fix crash concerning removal of dives from trips

Commit 6b283e598a 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>
This commit is contained in:
Berthold Stoeger 2018-11-21 18:13:53 +01:00 committed by Dirk Hohndel
parent 5d8830750a
commit 01d031383c

View file

@ -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;