diff options
author | Linus Nielsen Feltzing <linus@haxx.se> | 2003-11-04 16:47:05 +0000 |
---|---|---|
committer | Linus Nielsen Feltzing <linus@haxx.se> | 2003-11-04 16:47:05 +0000 |
commit | f97756e73370e0bb4ebe10960cf5db3f048bcc40 (patch) | |
tree | 7c7b5c14245e789d2a2bf63c21cc2665fbe725cd /apps/tree.c | |
parent | c6f234a4ccc917d16b21b89b00700391aaacca51 (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
Diffstat (limited to 'apps/tree.c')
-rw-r--r-- | apps/tree.c | 42 |
1 files changed, 29 insertions, 13 deletions
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 |