summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--firmware/mpeg.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/firmware/mpeg.c b/firmware/mpeg.c
index 104b6c5011..f149814dac 100644
--- a/firmware/mpeg.c
+++ b/firmware/mpeg.c
@@ -57,6 +57,7 @@ extern void bitswap(unsigned char *data, int length);
57 57
58extern char* playlist_peek(int steps); 58extern char* playlist_peek(int steps);
59extern int playlist_next(int steps); 59extern int playlist_next(int steps);
60extern int playlist_amount(void);
60extern void update_file_pos( int id, int pos ); 61extern void update_file_pos( int id, int pos );
61 62
62static char *units[] = 63static char *units[] =
@@ -709,6 +710,7 @@ static int add_track_to_tag_list(char *filename)
709/* If next_track is true, opens the next track, if false, opens prev track */ 710/* If next_track is true, opens the next track, if false, opens prev track */
710static int new_file(int steps) 711static int new_file(int steps)
711{ 712{
713 int max_steps = playlist_amount();
712 int start = num_tracks_in_memory() - 1; 714 int start = num_tracks_in_memory() - 1;
713 715
714 if (start < 0) 716 if (start < 0)
@@ -727,6 +729,10 @@ static int new_file(int steps)
727 if(mpeg_file < 0) { 729 if(mpeg_file < 0) {
728 DEBUGF("Couldn't open file: %s\n",trackname); 730 DEBUGF("Couldn't open file: %s\n",trackname);
729 steps++; 731 steps++;
732
733 /* Bail out if no file could be opened */
734 if(steps > max_steps)
735 return -1;
730 } 736 }
731 else 737 else
732 { 738 {