fix FS#9119 (crash if random folder list has no entries)
authorjdgordon <jdgordon@a1c6a512-1295-4272-9138-f99709370657>
Sun, 29 Jun 2008 02:19:53 +0000 (29 02:19 +0000)
committerjdgordon <jdgordon@a1c6a512-1295-4272-9138-f99709370657>
Sun, 29 Jun 2008 02:19:53 +0000 (29 02:19 +0000)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17862 a1c6a512-1295-4272-9138-f99709370657

apps/playlist.c

index 280d6dc..8f800f6 100644 (file)
@@ -1486,6 +1486,8 @@ static int get_next_dir(char *dir, bool is_forward, bool recursion)
         if (fd >= 0)
         {
             read(fd,&folder_count,sizeof(int));
+            if (!folder_count)
+                exit = true;
             while (!exit)
             {
                 i = rand()%folder_count;
@@ -1494,7 +1496,8 @@ static int get_next_dir(char *dir, bool is_forward, bool recursion)
                 if (check_subdir_for_music(buffer,"") ==0)
                     exit = true;
             }
-            strcpy(dir,buffer);
+            if (folder_count)
+                strcpy(dir,buffer);
             close(fd);
             *(tc->dirfilter) = dirfilter;
             reload_directory();