mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-27 20:58:47 +00:00
divelog: fix erroneous use of std::move()
This has to be applied to the object, not the pointer to the object.
Fixes a double-free crash introduced in 8cd451f
.
Alternatively, we could use std::swap() for C++98 charm and perhaps
better readability for people unfamiliar with C++11. Nowadays,
std::move() is more idiomatic though. Shrug.
Reported-by: Michael Keller <github@ike.ch>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
a38ea971a0
commit
a8d2b2ff70
1 changed files with 6 additions and 4 deletions
|
@ -40,8 +40,8 @@ divelog::divelog(divelog &&log) :
|
|||
dives(new dive_table),
|
||||
trips(new trip_table),
|
||||
sites(new dive_site_table),
|
||||
devices(std::move(log.devices)),
|
||||
filter_presets(std::move(log.filter_presets))
|
||||
devices(new device_table),
|
||||
filter_presets(new filter_preset_table)
|
||||
{
|
||||
*dives = empty_dive_table;
|
||||
*trips = empty_trip_table;
|
||||
|
@ -49,6 +49,8 @@ divelog::divelog(divelog &&log) :
|
|||
move_dive_table(log.dives, dives);
|
||||
move_trip_table(log.trips, trips);
|
||||
move_dive_site_table(log.sites, sites);
|
||||
*devices = std::move(*log.devices);
|
||||
*filter_presets = std::move(*log.filter_presets);
|
||||
}
|
||||
|
||||
struct divelog &divelog::operator=(divelog &&log)
|
||||
|
@ -56,8 +58,8 @@ struct divelog &divelog::operator=(divelog &&log)
|
|||
move_dive_table(log.dives, dives);
|
||||
move_trip_table(log.trips, trips);
|
||||
move_dive_site_table(log.sites, sites);
|
||||
devices = std::move(log.devices);
|
||||
filter_presets = std::move(log.filter_presets);
|
||||
*devices = std::move(*log.devices);
|
||||
*filter_presets = std::move(*log.filter_presets);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue