ui/ncurses/widgets: Add n_options check to widget_select_get_value
authorJeremy Kerr <jk@ozlabs.org>
Sun, 17 Nov 2013 08:35:49 +0000 (19:35 +1100)
committerJeremy Kerr <jk@ozlabs.org>
Fri, 22 Nov 2013 02:45:54 +0000 (10:45 +0800)
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
ui/ncurses/nc-widgets.c

index 98ea6be269774bf8186f7baedc1b597d0aa079be..d96480e960ab4d54e876a75655f2909777c1e0cd 100644 (file)
@@ -493,6 +493,8 @@ void widget_select_add_option(struct nc_widget_select *select, int value,
 
 int widget_select_get_value(struct nc_widget_select *select)
 {
+       if (!select->n_options)
+               return -1;
        return select->options[select->selected_option].val;
 }