From 0c4be83b31015b4732c0ae3677931be986b36576 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Fri, 11 Mar 2022 22:16:37 +0100 Subject: [PATCH] core: split proper divecomputer in split_divecomputer() split_divecomputer() is passed a dive and a divecomputer number. However, it accesses the currently visible dc! This would be a nasty bug if it werent for the fact that it is called when placing an undo command and there it is passed the current dive and divecomputer anyway. Nevertheless, fix this. Signed-off-by: Berthold Stoeger --- core/dive.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/dive.c b/core/dive.c index ab7be3ba3..eb6872bc8 100644 --- a/core/dive.c +++ b/core/dive.c @@ -3124,7 +3124,7 @@ struct dive *clone_delete_divecomputer(const struct dive *d, int dc_number) */ void split_divecomputer(const struct dive *src, int num, struct dive **out1, struct dive **out2) { - struct divecomputer *srcdc = get_dive_dc(current_dive, dc_number); + const struct divecomputer *srcdc = get_dive_dc_const(src, num); if (src && srcdc) { // Copy the dive, but only using the selected dive computer