From e9311545f5e101289a6d1f1b54eface70cf83717 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 14 Jan 2009 11:41:22 +0100 Subject: 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. --- src/playlist.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/playlist.c') 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); -- cgit v1.2.3