Commit bcfc62a3 authored by Max Kellermann's avatar Max Kellermann

PlaylistEdit, QueueSave: free the Song object after Append()

Fix for a major memory leak.
parent d1924867
...@@ -64,7 +64,9 @@ playlist::AppendFile(struct player_control &pc, ...@@ -64,7 +64,9 @@ playlist::AppendFile(struct player_control &pc,
if (song == nullptr) if (song == nullptr)
return PLAYLIST_RESULT_NO_SUCH_SONG; 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 enum playlist_result
...@@ -125,6 +127,8 @@ playlist::AppendURI(struct player_control &pc, ...@@ -125,6 +127,8 @@ playlist::AppendURI(struct player_control &pc,
enum playlist_result result = AppendSong(pc, song, added_id); enum playlist_result result = AppendSong(pc, song, added_id);
if (db != nullptr) if (db != nullptr)
db->ReturnSong(song); db->ReturnSong(song);
else
song->Free();
return result; return result;
} }
......
...@@ -128,4 +128,6 @@ queue_load_song(TextFile &file, const char *line, queue *queue) ...@@ -128,4 +128,6 @@ queue_load_song(TextFile &file, const char *line, queue *queue)
if (db != nullptr) if (db != nullptr)
db->ReturnSong(song); db->ReturnSong(song);
else
song->Free();
} }
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