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

Fix for a major memory leak.
This commit is contained in:
Max Kellermann 2013-10-18 01:12:47 +02:00
parent d1924867db
commit bcfc62a3f2
2 changed files with 7 additions and 1 deletions

View File

@ -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;
}

View File

@ -128,4 +128,6 @@ queue_load_song(TextFile &file, const char *line, queue *queue)
if (db != nullptr)
db->ReturnSong(song);
else
song->Free();
}