[BugFix] TagNav Custom Menu Entry Wrong title, crashing menu

Wrong title is due to the VIRT_PTR being 0 so when a NULL
string is passed through P2STR() you get langid(0)
that was 'Yes' now it will be 'Rockbox'

the crashing menu was due to a call to retrieve entries that wasn't guarded
against  getting called on a menu with no entries

g#5911 introduced this path to call custom_action for shuffled track adding

Change-Id: I3918debbe2e79dfc9595df56b05b1ae59ba94317
This commit is contained in:
William Wilgus 2025-02-11 01:00:28 -05:00
parent 2c1d31fcd9
commit 1ea5d57303
2 changed files with 19 additions and 16 deletions

View file

@ -91,6 +91,21 @@
# GoGear SA9200 gogearsa9200
# Samsung
# YH820/YH920/YH925 samsungyh*
<phrase>
id: LANG_ROCKBOX_TITLE
desc: main menu title
user: core
<source>
*: "Rockbox"
</source>
<dest>
*: "Rockbox"
</dest>
<voice>
*: "Rockbox"
</voice>
</phrase>
# First item will be shown when P2STR is passed a NULL pointer
<phrase>
id: LANG_SET_BOOL_YES
desc: bool true representation
@ -353,20 +368,6 @@
*: ""
</voice>
</phrase>
<phrase>
id: LANG_ROCKBOX_TITLE
desc: main menu title
user: core
<source>
*: "Rockbox"
</source>
<dest>
*: "Rockbox"
</dest>
<voice>
*: "Rockbox"
</voice>
</phrase>
<phrase>
id: LANG_BOOKMARK_MENU_RECENT_BOOKMARKS
desc: in the main menu

View file

@ -443,14 +443,14 @@ static int get_tag(int *tag)
if (first == match[0] && strncasecmp(tagstr, match + 1, tagstr_len - 1) == 0)
{
/* check for full match */
if ((ptrdiff_t)strlen(match) == tagstr_len)
if (match[tagstr_len] == '\0')
{
*tag = get_tag_symbol[i];
return 1;
}
}
}
logf("NO MATCH: %.*s\n", tagstr_len, tagstr);
logf("NO MATCH: %.*s\n", (int)tagstr_len, tagstr);
return -1;
}
@ -2293,6 +2293,8 @@ int tagtree_get_filename(struct tree_context* c, char *buf, int buflen)
int tagtree_get_custom_action(struct tree_context* c)
{
if (c->dirlength == 0)
return 0;
return tagtree_get_entry(c, c->selected_item)->customaction;
}