nconfig: Fix segfault when menu is empty
[firefly-linux-kernel-4.4.55.git] / scripts / kconfig / nconf.c
index fb54c98874bc9985eb15e6f7b55e70b5cc75aa91..2ba71bcd38e65381aa347e093a2dc7b338d03dc0 100644 (file)
@@ -676,6 +676,8 @@ static void *item_data(void)
        struct mitem *mcur;
 
        cur = current_item(curses_menu);
+       if (!cur)
+               return NULL;
        mcur = (struct mitem *) item_userptr(cur);
        return mcur->usrptr;
 
@@ -984,7 +986,7 @@ static void build_conf(struct menu *menu)
                                break;
                        default:
                                tmp = 2 + strlen(sym_get_string_value(sym));
-                               item_make(menu, 's', "(%s)",
+                               item_make(menu, 's', "    (%s)",
                                                sym_get_string_value(sym));
                                tmp = indent - tmp + 4;
                                if (tmp < 0)
@@ -1072,8 +1074,8 @@ static void show_menu(const char *prompt, const char *instructions,
 
        /* position the menu at the middle of the screen */
        scale_menu(curses_menu, &maxy, &maxx);
-       maxx = min(maxx, mwin_max_cols);
-       maxy = mwin_max_lines-1;
+       maxx = min(maxx, mwin_max_cols-2);
+       maxy = mwin_max_lines-2;
        menu_window = derwin(main_window,
                        maxy,
                        maxx,