Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp6343186rwi; Sun, 23 Oct 2022 23:16:28 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5Ou89N64Bw4UG6ViM9Mx69L8hn4a1oV9yl96ApuMpbUj+x8moskE7hPGEtnMvNMLHM3uD1 X-Received: by 2002:a17:907:8688:b0:791:91a0:fdb3 with SMTP id qa8-20020a170907868800b0079191a0fdb3mr24716047ejc.499.1666592177799; Sun, 23 Oct 2022 23:16:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666592177; cv=none; d=google.com; s=arc-20160816; b=GYO22Rs3353v0YlMTtwoKxiEBiVsbZCo+X6FqK+xckhzSpFgKmPjepJbZk+5H96BtF Vtvk4K3TCCANxYsDdBxu0iZgFdEQQOlEK8xx9uXUt8Q9EDI2rzl3UNwbFlyltyIEqh2c JCtpjEl+LrCnU3LXFNNn/RI3rrZ58KNrgG6iCBRan3qGM/xcQCyIPqzFxGDT3wTPGT9G 9sMmAS7ZqMHy8pi6jPmJIKMYD9jU20JdSF3aIRoZPrSH54z5Bii+sFNVW38CHNFJYXZe brxyVhE02Q2zQwFMKGHTYXEYpxHDYQujl0Q44I2xumzmSt7aTPWzpr5CWMcrp/EKK6YD dYmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=VqBRL5gPHjrjvnpC4r0YoRWcyailozSgdCXt4S2Prrc=; b=ikQZMDzCiPtV00Ihg09vvble1Mc5AR6w2w9WLcNlwx9KcIK4DDHQeq6tGUSFUmoCvn ujQkpXm/FrAlXChSbME0RvnMcgNPmAi2rvYyA17HCnHtm6J4u2Py/QXvhlssOh2bk1BC SifDhRqGH48Vi0YZXranq10JeN/F81qep5UliyWqrma9VYDGKTFNxg+kDhdnR+frSk82 W/Nmc58YduN3gz8B9v90uHOaTD8Sh0H9cXTWccxmoVDkZ7oafFZsi0WHPgj5ydm4SfSN fvGgU4DT/78VrCzYG2h+heF35jFk6pbZTfKMX5C3lGLULPFQYvFY1njI9f09Ppwfit6C K9tA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qh3-20020a170906eca300b007a2d966eeccsi4231062ejb.686.2022.10.23.23.15.53; Sun, 23 Oct 2022 23:16:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230175AbiJXF4h (ORCPT + 99 others); Mon, 24 Oct 2022 01:56:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58326 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229875AbiJXF4g (ORCPT ); Mon, 24 Oct 2022 01:56:36 -0400 Received: from mail.nfschina.com (mail.nfschina.com [124.16.136.209]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0452056002; Sun, 23 Oct 2022 22:56:34 -0700 (PDT) Received: from localhost (unknown [127.0.0.1]) by mail.nfschina.com (Postfix) with ESMTP id 219CF1E80D74; Mon, 24 Oct 2022 13:55:18 +0800 (CST) X-Virus-Scanned: amavisd-new at test.com Received: from mail.nfschina.com ([127.0.0.1]) by localhost (mail.nfschina.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 1Tfw875md579; Mon, 24 Oct 2022 13:55:15 +0800 (CST) Received: from localhost.localdomain (unknown [219.141.250.2]) (Authenticated sender: zeming@nfschina.com) by mail.nfschina.com (Postfix) with ESMTPA id 427D91E80CA5; Mon, 24 Oct 2022 13:55:15 +0800 (CST) From: Li zeming To: masahiroy@kernel.org Cc: linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, Li zeming Subject: [PATCH] lxdialog: menubox: Add malloc allocation judgment Date: Mon, 24 Oct 2022 13:56:29 +0800 Message-Id: <20221024055629.178198-1-zeming@nfschina.com> X-Mailer: git-send-email 2.18.2 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add menu_item Only when the pointer judges that the pointer is valid can function code be executed. Signed-off-by: Li zeming --- scripts/kconfig/lxdialog/menubox.c | 53 +++++++++++++++--------------- 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/scripts/kconfig/lxdialog/menubox.c b/scripts/kconfig/lxdialog/menubox.c index 58c2f8afe59b..2ae263ad477e 100644 --- a/scripts/kconfig/lxdialog/menubox.c +++ b/scripts/kconfig/lxdialog/menubox.c @@ -55,34 +55,35 @@ static void do_print_item(WINDOW * win, const char *item, int line_y, { int j; char *menu_item = malloc(menu_width + 1); + if (menu_item) { + strncpy(menu_item, item, menu_width - item_x); + menu_item[menu_width - item_x] = '\0'; + j = first_alpha(menu_item, "YyNnMmHh"); - strncpy(menu_item, item, menu_width - item_x); - menu_item[menu_width - item_x] = '\0'; - j = first_alpha(menu_item, "YyNnMmHh"); - - /* Clear 'residue' of last item */ - wattrset(win, dlg.menubox.atr); - wmove(win, line_y, 0); -#if OLD_NCURSES - { - int i; - for (i = 0; i < menu_width; i++) - waddch(win, ' '); - } -#else - wclrtoeol(win); -#endif - wattrset(win, selected ? dlg.item_selected.atr : dlg.item.atr); - mvwaddstr(win, line_y, item_x, menu_item); - if (hotkey) { - wattrset(win, selected ? dlg.tag_key_selected.atr - : dlg.tag_key.atr); - mvwaddch(win, line_y, item_x + j, menu_item[j]); - } - if (selected) { - wmove(win, line_y, item_x + 1); + /* Clear 'residue' of last item */ + wattrset(win, dlg.menubox.atr); + wmove(win, line_y, 0); + #if OLD_NCURSES + { + int i; + for (i = 0; i < menu_width; i++) + waddch(win, ' '); + } + #else + wclrtoeol(win); + #endif + wattrset(win, selected ? dlg.item_selected.atr : dlg.item.atr); + mvwaddstr(win, line_y, item_x, menu_item); + if (hotkey) { + wattrset(win, selected ? dlg.tag_key_selected.atr + : dlg.tag_key.atr); + mvwaddch(win, line_y, item_x + j, menu_item[j]); + } + if (selected) { + wmove(win, line_y, item_x + 1); + } + free(menu_item); } - free(menu_item); wrefresh(win); } -- 2.18.2