From 855466df402bd9e8b3455c62bed08afa35eaf1e4 Mon Sep 17 00:00:00 2001 From: Romain Bignon Date: Fri, 13 Feb 2009 11:12:31 +0100 Subject: [PATCH] playlist_edit: improved range checks in shufflePlaylist() --- src/playlist_edit.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/playlist_edit.c b/src/playlist_edit.c index 2c0c62eb6..576cc8780 100644 --- a/src/playlist_edit.c +++ b/src/playlist_edit.c @@ -357,7 +357,12 @@ void shufflePlaylist(struct playlist *playlist, unsigned start, unsigned end) { const struct song *queued; - if (end-1 <= start || end > queue_length(&playlist->queue)) + if (end > queue_length(&playlist->queue)) + /* correct the "end" offset */ + end = queue_length(&playlist->queue); + + if ((start+1) >= end) + /* needs at least two entries. */ return; queued = playlist_get_queued_song(playlist);