aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-01-14 11:41:22 +0100
committerMax Kellermann <max@duempel.org>2009-01-14 11:41:22 +0100
commite9311545f5e101289a6d1f1b54eface70cf83717 (patch)
tree1297bf7d965b03b142bac02acc61a887e387bb28 /src
parent525c507ac56815c295a3c671725c60bfe03baabc (diff)
downloadmpd-e9311545f5e101289a6d1f1b54eface70cf83717.tar.gz
mpd-e9311545f5e101289a6d1f1b54eface70cf83717.tar.xz
mpd-e9311545f5e101289a6d1f1b54eface70cf83717.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/playlist.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/playlist.c b/src/playlist.c
index 96eff0a6f..1d2fb7306 100644
--- a/src/playlist.c
+++ b/src/playlist.c
@@ -743,7 +743,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);