diff --git a/commands/menu.c b/commands/menu.c index 72db26e..ddc9c3a 100644 --- a/commands/menu.c +++ b/commands/menu.c @@ -147,7 +147,7 @@ if (!m->name) goto free; - menu_add_title(m, strdup(cm->description)); + menu_add_title(m, cm->description); ret = menu_add(m); diff --git a/common/boot.c b/common/boot.c index 123b874..4306319 100644 --- a/common/boot.c +++ b/common/boot.c @@ -44,7 +44,7 @@ if (IS_ENABLED(CONFIG_MENU)) { bootentries->menu = menu_alloc(); - menu_add_title(bootentries->menu, basprintf("boot")); + menu_add_title(bootentries->menu, "boot"); } return bootentries; diff --git a/common/menu.c b/common/menu.c index 64df458..e757216 100644 --- a/common/menu.c +++ b/common/menu.c @@ -526,18 +526,17 @@ * @display: NULL or pointer to the string which will be freed in this function. * If NULL or zero length string is provided, default title will be added. */ -void menu_add_title(struct menu *m, char *display) +void menu_add_title(struct menu *m, const char *display) { char *tmp, *src, *dst; int lines = 1; int i; - if (!display || !strlen(display)) { - free(display); - display = xasprintf("Menu : %s", m->name ? m->name : ""); - } + if (!display || !strlen(display)) + src = dst = tmp = xasprintf("Menu : %s", m->name ? m->name : ""); + else + src = dst = tmp = xstrdup(display); - src = dst = tmp = xstrdup(display); /* Count lines and separate single string into multiple strings */ while (*src) { if (*src == '\\') { @@ -575,6 +574,5 @@ } free(tmp); - free(display); } EXPORT_SYMBOL(menu_add_title); diff --git a/include/menu.h b/include/menu.h index 3e704a8..2fef064 100644 --- a/include/menu.h +++ b/include/menu.h @@ -91,7 +91,7 @@ int menu_set_selected(struct menu *m, int num); int menu_set_auto_select(struct menu *m, int delay); struct menu* menu_get_menus(void); -void menu_add_title(struct menu *m, char *display); +void menu_add_title(struct menu *m, const char *display); /* * menu entry functions