FS#12008 - Empty menus lead to NULL pointer access

Attached to Project: Rockbox
Opened by Thomas Jarosch (thomasjfox) - Sunday, 13 March 2011, 09:59 GMT
Task Type Bugs
Category User Interface
Status New
Assigned To No-one
Operating System All players
Severity Low
Priority Normal
Reported Version Daily build (which?)
Due in Version Undecided
Due Date Undecided
Percent Complete 0%
Votes 0
Private No



empty menu items crash rockbox due to NULL pointer access.
Easily reproducable with the "LCD settings" in RaaA / SDL app build.

The resulting valgrind trace looks like this:
==22619== Invalid read of size 4
==22619== at 0x407FDA: do_menu (menu.c:555)
==22619== by 0x41B198: miscscrn (root_menu.c:323)
==22619== by 0x41B377: load_screen (root_menu.c:520)
==22619== by 0x41B72A: root_menu (root_menu.c:688)
==22619== by 0x406DFA: main (main.c:196)
==22619== Address 0x0 is not stack'd, malloc'd or (recently) free'd

Should we protect against "menu->submenus" being NULL or
should the menu system hide empty menus without any items at all?

This task depends upon

Comment by Thomas Martitz (kugel.) - Sunday, 13 March 2011, 11:50 GMT
Doesn't crash on android. It's just empty.
Comment by Jonathan Gordon (jdgordon) - Sunday, 13 March 2011, 11:53 GMT
press ACTION_STD_OK when you are in the empty menu...
Comment by Thomas Martitz (kugel.) - Sunday, 13 March 2011, 11:55 GMT
That crashes indeed.