diff options
author | Max Kellermann <max@duempel.org> | 2016-02-28 11:08:00 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2016-02-28 11:08:00 +0100 |
commit | fe4b1f96f1b061d58f81f47652d9c3c9f4355f67 (patch) | |
tree | bc28a5340ff3eedf6625b442a3e4dd7ca556ad1d /src/SongLoader.cxx | |
parent | 9de984f7f8ea98fcac544ad3dc046d0a57dccfba (diff) |
SongLoader: use temporary stack variable, no heap allocation
Improved exception-safety.
Diffstat (limited to 'src/SongLoader.cxx')
-rw-r--r-- | src/SongLoader.cxx | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/SongLoader.cxx b/src/SongLoader.cxx index 637c80284..e68edbef4 100644 --- a/src/SongLoader.cxx +++ b/src/SongLoader.cxx @@ -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 * |