core: on import remove merged dives from trip/divesite

When dives were merged on import, they were not unregistered
from their dive site and trip before being deleted. Thus, these
tables had stale pointers, which would ultimate lead to crashes.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2020-11-01 00:58:35 +01:00 committed by Dirk Hohndel
parent 43f15f1b48
commit b2b3544f3f

View file

@ -857,6 +857,10 @@ static void merge_imported_dives(struct dive_table *table)
merged->dive_site = NULL;
add_dive_to_dive_site(merged, ds);
}
unregister_dive_from_dive_site(prev);
unregister_dive_from_dive_site(dive);
unregister_dive_from_trip(prev);
unregister_dive_from_trip(dive);
/* Overwrite the first of the two dives and remove the second */
free_dive(prev);