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 <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2022-03-11 22:16:37 +01:00 committed by Dirk Hohndel
parent c2a7382b10
commit 0c4be83b31

View file

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