summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorMasahisa Kojima <masahisa.kojima@linaro.org>2022-04-28 17:09:37 +0900
committerHeinrich Schuchardt <heinrich.schuchardt@canonical.com>2022-05-03 21:39:22 +0200
commit7f67525f99d8158f668af8198cc1d089a3dc4ee8 (patch)
tree72d74a038949af77cf5487eccb4d2074fec4766f /common
parentc23bb03465c1107495b90c4b396d37a0bbe90bfc (diff)
menu: menu_get_choice() return -ENOENT if menu item is empty
menu_get_choice() needs to handle the case that menu item is empty. In this case, menu_get_choice() returns -ENOENT. Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org> Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Diffstat (limited to 'common')
-rw-r--r--common/menu.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/common/menu.c b/common/menu.c
index b577d80b4f..f5fc6930a2 100644
--- a/common/menu.c
+++ b/common/menu.c
@@ -271,6 +271,9 @@ int menu_get_choice(struct menu *m, void **choice)
if (!m || !choice)
return -EINVAL;
+ if (!m->item_cnt)
+ return -ENOENT;
+
if (!m->prompt)
return menu_default_choice(m, choice);