summaryrefslogtreecommitdiffstats
path: root/apps/tree.c
diff options
context:
space:
mode:
authorChristian Soffke <christian.soffke@gmail.com>2022-10-21 13:34:31 +0200
committerWilliam Wilgus <me.theuser@yahoo.com>2022-10-30 11:57:33 -0400
commit246152a671b2fc08b39cc897523b8a325d1205e0 (patch)
tree8762dfcbfa2da5be38046327d3e3a49831ee568e /apps/tree.c
parentb4e7c60c6d74e076fb731ea43e6a6826652468ca (diff)
downloadrockbox-246152a671b2fc08b39cc897523b8a325d1205e0.tar.gz
rockbox-246152a671b2fc08b39cc897523b8a325d1205e0.zip
Database: Fix possible crash
The File Browser and Database apparently share the same selected_item_history, which means that selected_item can be -1 even in the context of the database, This leads to tree_get_file_position being called in id3db mode, which isn't safe to do. Change-Id: I46151e8a823afab0b57ad839cde13f6072b8917b
Diffstat (limited to 'apps/tree.c')
-rw-r--r--apps/tree.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/apps/tree.c b/apps/tree.c
index 2bccefa7a1..6e9ca106c0 100644
--- a/apps/tree.c
+++ b/apps/tree.c
@@ -392,8 +392,11 @@ static int update_dir(void)
/* if selected item is undefined */
if (tc.selected_item == -1)
{
- /* use lastfile to determine the selected item */
- tc.selected_item = tree_get_file_position(lastfile);
+#ifdef HAVE_TAGCACHE
+ if (!id3db)
+#endif
+ /* use lastfile to determine the selected item */
+ tc.selected_item = tree_get_file_position(lastfile);
/* If the file doesn't exists, select the first one (default) */
if(tc.selected_item < 0)