summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilliam Wilgus <me.theuser@yahoo.com>2018-12-20 20:41:21 -0600
committerWilliam Wilgus <me.theuser@yahoo.com>2018-12-20 20:41:21 -0600
commitf08d218e676f9ee8b5c26e755088671baf3a70b7 (patch)
treed3891a7d609efb19d468d3663a7ac1d21a21bf9f
parent28f91ff3dc6e0d7f98c793d022e405781f292eb6 (diff)
downloadrockbox-f08d218e676f9ee8b5c26e755088671baf3a70b7.tar.gz
rockbox-f08d218e676f9ee8b5c26e755088671baf3a70b7.tar.bz2
rockbox-f08d218e676f9ee8b5c26e755088671baf3a70b7.zip
Fix tree.c->dirbrowse panic from database browser
I set up panics on invalid entries throughout tree.c dirbrowser was checking for file attributes even when the result was unused, the database browser called this code with an invalid (to the tagcache) index This patch fixes that oversight and also adds __func__ to the panics for easier sleuthing in the future Change-Id: Ie1d6511423bba48125e4916b1c3049c048abaee0
-rw-r--r--apps/tree.c34
1 files changed, 17 insertions, 17 deletions
diff --git a/apps/tree.c b/apps/tree.c
index ddaf955ce6..fc7998ad7d 100644
--- a/apps/tree.c
+++ b/apps/tree.c
@@ -137,7 +137,7 @@ static const char* tree_get_filename(int selected_item, void *data,
{
struct entry *entry = tree_get_entry_at(local_tc, selected_item);
if (!entry)
- panicf("Invalid tree entry");
+ panicf("Invalid tree entry %s", __func__);
name = entry->name;
attr = entry->attr;
}
@@ -181,7 +181,7 @@ static int tree_get_filecolor(int selected_item, void * data)
struct tree_context * local_tc=(struct tree_context *)data;
struct entry *entry = tree_get_entry_at(local_tc, selected_item);
if (!entry)
- panicf("Invalid tree entry");
+ panicf("Invalid tree entry %s", __func__);
return filetype_get_color(entry->name, entry->attr);
}
@@ -200,7 +200,7 @@ static enum themable_icons tree_get_fileicon(int selected_item, void * data)
{
struct entry *entry = tree_get_entry_at(local_tc, selected_item);
if (!entry)
- panicf("Invalid tree entry");
+ panicf("Invalid tree entry %s", __func__);
return filetype_get_icon(entry->attr);
}
@@ -225,7 +225,7 @@ static int tree_voice_cb(int selected_item, void * data)
{
struct entry *entry = tree_get_entry_at(local_tc, selected_item);
if (!entry)
- panicf("Invalid tree entry");
+ panicf("Invalid tree entry %s", __func__);
name = entry->name;
attr = entry->attr;
@@ -689,20 +689,20 @@ static int dirbrowse(void)
/* nothing to do if no files to display */
if ( numentries == 0 )
break;
-
- struct entry *entry = tree_get_entry_at(&tc, tc.selected_item);
- if (!entry)
- panicf("Invalid tree entry");
-
- short attr = entry->attr;
- if ((tc.browse->flags & BROWSE_SELECTONLY) &&
- !(attr & ATTR_DIRECTORY))
+ if (tc.browse->flags & BROWSE_SELECTONLY)
{
- tc.browse->flags |= BROWSE_SELECTED;
- get_current_file(tc.browse->buf, tc.browse->bufsize);
- return GO_TO_PREVIOUS;
- }
+ struct entry *entry = tree_get_entry_at(&tc, tc.selected_item);
+ if (!entry)
+ panicf("Invalid tree entry %s", __func__);
+ short attr = entry->attr;
+ if(!(attr & ATTR_DIRECTORY))
+ {
+ tc.browse->flags |= BROWSE_SELECTED;
+ get_current_file(tc.browse->buf, tc.browse->bufsize);
+ return GO_TO_PREVIOUS;
+ }
+ }
#ifdef HAVE_TAGCACHE
switch (id3db?tagtree_enter(&tc):ft_enter(&tc))
#else
@@ -823,7 +823,7 @@ static int dirbrowse(void)
{
struct entry *entry = tree_get_entry_at(&tc, tc.selected_item);
if (!entry)
- panicf("Invalid tree entry");
+ panicf("Invalid tree entry %s", __func__);
attr = entry->attr;