Skip to content

Commit

Permalink
core: split proper divecomputer in split_divecomputer()
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
bstoeger authored and dirkhh committed Mar 13, 2022
1 parent c2a7382 commit 0c4be83
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion core/dive.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0c4be83

Please sign in to comment.