db/simple: fix dangling LightSong::tag reference in moved ExportedSong
After commit 1afa33c3c7
, an old bug was revealed:
SimpleDatabase::GetSong() constructs an ExportedSong instance by
moving the return value of Song::Export(), which causes the
LightSong::tag field to be dangling on the moved-from
ExportedSong::tag_buffer. This broke tags from CUE sheets.
Closes https://github.com/MusicPlayerDaemon/MPD/issues/1070
This commit is contained in:
@@ -37,6 +37,15 @@ public:
|
||||
ExportedSong(const char *_uri, Tag &&_tag) noexcept
|
||||
:LightSong(_uri, tag_buffer),
|
||||
tag_buffer(std::move(_tag)) {}
|
||||
|
||||
/* this custom move constructor is necessary so LightSong::tag
|
||||
points to this instance's #Tag field instead of leaving a
|
||||
dangling reference to the source object's #Tag field */
|
||||
ExportedSong(ExportedSong &&src) noexcept
|
||||
:LightSong(src, tag_buffer),
|
||||
tag_buffer(std::move(src.tag_buffer)) {}
|
||||
|
||||
ExportedSong &operator=(ExportedSong &&) = delete;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user