menu: Fix NULL dereference when DEFAULT_ENTRY is out of range with TIMEOUT=0
diff --git a/common/menu.c b/common/menu.c
index 14e9fdbe..7d71a9ab 100644
--- a/common/menu.c
+++ b/common/menu.c
@@ -1322,7 +1322,7 @@ noreturn void _menu(bool first_run) {
}
if (!skip_timeout && !timeout) {
- if (max_entries == 0 || selected_menu_entry->sub != NULL) {
+ if (max_entries == 0 || selected_menu_entry == NULL || selected_menu_entry->sub != NULL) {
quiet = false;
print("Default entry is not valid or directory, booting to menu.\n");
skip_timeout = true;
