Commit fe4b1f96 authored by Max Kellermann's avatar Max Kellermann

SongLoader: use temporary stack variable, no heap allocation

Improved exception-safety.
parent 9de984f7
......@@ -65,15 +65,14 @@ SongLoader::LoadFile(const char *path_utf8, Path path_fs, Error &error) const
}
#endif
DetachedSong *song = new DetachedSong(path_utf8);
if (!song->LoadFile(path_fs)) {
DetachedSong song(path_utf8);
if (!song.LoadFile(path_fs)) {
error.Set(playlist_domain, int(PlaylistResult::NO_SUCH_SONG),
"No such file");
delete song;
return nullptr;
}
return song;
return new DetachedSong(std::move(song));
}
DetachedSong *
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment