]> git.sesse.net Git - vlc/commitdiff
Fix a bug when shuffling playlist with 1 item
authorJérome Decoodt <djc@videolan.org>
Sun, 2 Jan 2005 22:45:36 +0000 (22:45 +0000)
committerJérome Decoodt <djc@videolan.org>
Sun, 2 Jan 2005 22:45:36 +0000 (22:45 +0000)
src/playlist/sort.c

index 38b15cc0c768df2f2a2a28f7c039e3ad825d6758..72e1d97627298a964e9d09512955d05231befdbc 100644 (file)
@@ -147,8 +147,12 @@ int playlist_ItemArraySort( playlist_t *p_playlist, int i_items,
     {
         for( i_position = 0; i_position < i_items ; i_position ++ )
         {
-            int i_new  = rand() % (i_items - 1);
+            int i_new;
 
+            if( i_items > 1 )
+                i_new = rand() % (i_items - 1);
+            else
+                i_new = 0;
             p_temp = pp_items[i_position];
             pp_items[i_position] = pp_items[i_new];
             pp_items[i_new] = p_temp;