playlist: fixed "next song" check

Check if the "current+1" position is actually valid.
This commit is contained in:
Vladimir S Eremin 2009-02-09 13:29:00 +01:00 committed by Max Kellermann
parent e2f22229a6
commit d9ce8d8342
1 changed files with 2 additions and 3 deletions

View File

@ -338,12 +338,11 @@ int getPlaylistNextSong(const struct playlist *playlist)
{
if (playlist->current >= 0)
{
if (queue_length(&playlist->queue) > 1)
if (playlist->current + 1 < (int)queue_length(&playlist->queue))
return queue_order_to_position(&playlist->queue,
playlist->current + 1);
else if (playlist->queue.repeat == 1)
return queue_order_to_position(&playlist->queue,
playlist->current);
return queue_order_to_position(&playlist->queue, 0);
}
return -1;