X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=cmd%2Fbootmenu.c;h=7f88c1ed63252ba046f07a9b1b59e70ff06d8dad;hb=29dada9c2e1637aede9985ded2959342e2d4a458;hp=21f353ffd3c76cdaf2aa1bdd3f7fc05a9faa62a2;hpb=e8f80a5a58c9b506453cc0780687e8ed457d30a6;p=oweals%2Fu-boot.git diff --git a/cmd/bootmenu.c b/cmd/bootmenu.c index 21f353ffd3..7f88c1ed63 100644 --- a/cmd/bootmenu.c +++ b/cmd/bootmenu.c @@ -253,6 +253,7 @@ static struct bootmenu_data *bootmenu_create(int delay) int len; char *sep; + char *default_str; struct bootmenu_entry *entry; menu = malloc(sizeof(struct bootmenu_data)); @@ -263,6 +264,10 @@ static struct bootmenu_data *bootmenu_create(int delay) menu->active = 0; menu->first = NULL; + default_str = env_get("bootmenu_default"); + if (default_str) + menu->active = (int)simple_strtol(default_str, NULL, 10); + while ((option = bootmenu_getoption(i))) { sep = strchr(option, '='); if (!sep) { @@ -346,6 +351,12 @@ static struct bootmenu_data *bootmenu_create(int delay) } menu->count = i; + + if ((menu->active >= menu->count)||(menu->active < 0)) { //ensure active menuitem is inside menu + printf("active menuitem (%d) is outside menu (0..%d)\n",menu->active,menu->count-1); + menu->active=0; + } + return menu; cleanup: