playlist: safely search the playlist for deleted song

When a song file is deleted during database update, all pointers to it
must be removed from the playlist.  The "for" loop in
deleteASongFromPlaylist() did not deal with multiple copies of the
deleted song properly, and left instances of the (to-be-invalidated)
pointer in.  Fix this by reversing the loop.
This commit is contained in:
Max Kellermann
2009-01-14 11:41:22 +01:00
parent 2af1742fcf
commit 2c540ee8a4
2 changed files with 8 additions and 1 deletions

View File

@@ -764,7 +764,7 @@ deleteASongFromPlaylist(const struct song *song)
if (NULL == playlist.songs)
return;
for (unsigned i = 0; i < playlist.length; i++)
for (int i = playlist.length - 1; i >= 0; --i)
if (song == playlist.songs[i])
deleteFromPlaylist(i);