From 038cb53fa8e19592b9c7021176fda194799f1d51 Mon Sep 17 00:00:00 2001 From: Jeremy Kerr Date: Tue, 7 May 2013 14:36:51 +0800 Subject: ui/nc: Handle cui_opt_data with no boot option more gracefully We can currently segfault petitboot by escaping from the option editor (before entering any details), then trying to boot the new, empty option. This change adds some sanity checks to prevent a segfault. Signed-off-by: Jeremy Kerr --- ui/ncurses/nc-cui.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'ui') diff --git a/ui/ncurses/nc-cui.c b/ui/ncurses/nc-cui.c index 342b603..167c2bb 100644 --- a/ui/ncurses/nc-cui.c +++ b/ui/ncurses/nc-cui.c @@ -109,6 +109,11 @@ static int cui_boot(struct pmenu_item *item) assert(cui->current == &cui->main->scr); pb_log("%s: %s\n", __func__, cod->name); + if (!cod->opt) { + pb_log("%s: missing opt?\n", __func__); + return -1; + } + nc_scr_status_printf(cui->current, "Booting %s...", cod->name); def_prog_mode(); -- cgit v1.2.1