summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Nielsen Feltzing <linus@haxx.se>2003-11-04 16:47:05 +0000
committerLinus Nielsen Feltzing <linus@haxx.se>2003-11-04 16:47:05 +0000
commitf97756e73370e0bb4ebe10960cf5db3f048bcc40 (patch)
tree7c7b5c14245e789d2a2bf63c21cc2665fbe725cd
parentc6f234a4ccc917d16b21b89b00700391aaacca51 (diff)
Patch #835815 by Henrik Backe, prevents stack overflow in .rockbox browser.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@4015 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/lang/english.lang5
-rw-r--r--apps/tree.c42
2 files changed, 34 insertions, 13 deletions
diff --git a/apps/lang/english.lang b/apps/lang/english.lang
index a3d8a03858..b4013fd90a 100644
--- a/apps/lang/english.lang
+++ b/apps/lang/english.lang
@@ -1767,3 +1767,8 @@ id: LANG_LINE_IN
desc: in settings_menu
eng: "Line In"
new:
+
+id: LANG_NO_FILES
+desc: in settings_menu
+eng: "No files"
+new:
diff --git a/apps/tree.c b/apps/tree.c
index fb62b0ede8..0b41b3af46 100644
--- a/apps/tree.c
+++ b/apps/tree.c
@@ -840,11 +840,18 @@ static bool dirbrowse(char *root, int *dirfilter)
memcpy(currdir,root,sizeof(currdir));
if (*dirfilter < NUM_FILTER_MODES)
- start_resume(true);
+ start_resume(true);
numentries = showdir(currdir, dirstart, dirfilter);
if (numentries == -1)
return false; /* currdir is not a directory */
+
+ if (*dirfilter > NUM_FILTER_MODES && numentries==0)
+ {
+ splash(HZ*2, 0, true, str(LANG_NO_FILES));
+ return false; /* No files found for rockbox_browser() */
+ }
+
update_all = true;
put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, true);
@@ -1171,10 +1178,13 @@ static bool dirbrowse(char *root, int *dirfilter)
break;
case TREE_MENU:
- lcd_stop_scroll();
- if (main_menu())
- reload_root = true;
- restore = true;
+ if (*dirfilter < NUM_FILTER_MODES)
+ {
+ lcd_stop_scroll();
+ if (main_menu())
+ reload_root = true;
+ restore = true;
+ }
break;
case BUTTON_ON:
@@ -1206,19 +1216,25 @@ static bool dirbrowse(char *root, int *dirfilter)
#ifdef HAVE_RECORDER_KEYPAD
case BUTTON_F2:
- if (f2_screen())
- reload_root = true;
- restore = true;
- break;
+ if (*dirfilter < NUM_FILTER_MODES)
+ {
+ if (f2_screen())
+ reload_root = true;
+ restore = true;
+ break;
+ }
case BUTTON_F3:
- if (f3_screen())
- reload_root = true;
+ if (*dirfilter < NUM_FILTER_MODES)
+ {
+ if (f3_screen())
+ reload_root = true;
#ifdef HAVE_LCD_BITMAP
- tree_max_on_screen = (LCD_HEIGHT - MARGIN_Y) / fh;
+ tree_max_on_screen = (LCD_HEIGHT - MARGIN_Y) / fh;
#endif
- restore = true;
+ restore = true;
+ }
break;
#endif