diff options
author | Max Kellermann <max@duempel.org> | 2013-10-18 01:12:47 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2013-10-18 01:12:47 +0200 |
commit | bcfc62a3f2bd79faeef55234bcdfaa10c3577273 (patch) | |
tree | 0942b68f235a2f77ffc3f6f793e898a7865c5f24 /src | |
parent | d1924867db6fff577274966721d0ff855a912ae9 (diff) | |
download | mpd-bcfc62a3f2bd79faeef55234bcdfaa10c3577273.tar.gz mpd-bcfc62a3f2bd79faeef55234bcdfaa10c3577273.tar.xz mpd-bcfc62a3f2bd79faeef55234bcdfaa10c3577273.zip |
PlaylistEdit, QueueSave: free the Song object after Append()
Fix for a major memory leak.
Diffstat (limited to '')
-rw-r--r-- | src/PlaylistEdit.cxx | 6 | ||||
-rw-r--r-- | src/QueueSave.cxx | 2 |
2 files changed, 7 insertions, 1 deletions
diff --git a/src/PlaylistEdit.cxx b/src/PlaylistEdit.cxx index 3cb68a1ab..9ef671a19 100644 --- a/src/PlaylistEdit.cxx +++ b/src/PlaylistEdit.cxx @@ -64,7 +64,9 @@ playlist::AppendFile(struct player_control &pc, if (song == nullptr) return PLAYLIST_RESULT_NO_SUCH_SONG; - return AppendSong(pc, song, added_id); + const auto result = AppendSong(pc, song, added_id); + song->Free(); + return result; } enum playlist_result @@ -125,6 +127,8 @@ playlist::AppendURI(struct player_control &pc, enum playlist_result result = AppendSong(pc, song, added_id); if (db != nullptr) db->ReturnSong(song); + else + song->Free(); return result; } diff --git a/src/QueueSave.cxx b/src/QueueSave.cxx index 7fe985a69..c45390097 100644 --- a/src/QueueSave.cxx +++ b/src/QueueSave.cxx @@ -128,4 +128,6 @@ queue_load_song(TextFile &file, const char *line, queue *queue) if (db != nullptr) db->ReturnSong(song); + else + song->Free(); } |