Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp6324792rwi; Sun, 23 Oct 2022 22:57:07 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5ZDsETKOxMy1A5AJyIbz9bGMPeyPWVUxxxt31hhGIbOSQpqHwWyKDZHjf6ft7YH2tYp9qq X-Received: by 2002:a05:6402:2211:b0:461:5d0a:6678 with SMTP id cq17-20020a056402221100b004615d0a6678mr12860634edb.378.1666591026751; Sun, 23 Oct 2022 22:57:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666591026; cv=none; d=google.com; s=arc-20160816; b=vnbIBkdbuaFloFu4D/r8Dfocy3sFdXOQRiwCTWHkxHrX+Umkly2vjF+gtV/wLTXEQo n0mXwtRQ7j6jVE/+/DKkmKLvBXuNPdkq3QO95RRYESodkXWhYvxz/vL4FMFIrZkgbukV SWA+50S3ZlJu4gV19ymWVGty3soc3tJJtrzWr1qbTXAXa/eTuwq6U7ZdZ4juVw8X61mD wb6Mbml0l3Gi2I9dUfsiK5RmwPqVwUWQD6Ud52aQdbBcWW8L6lTcKC87C4c2IjAN4/4V S1CRFOLTv4nWhfMmSc00qCefoZJMKObn25r4ckC5DBaZIFoATcg/qU8WEbmogVG2G02n QVzg== 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=58N+XU/JAntkaSq8jTbK3dNm0n44VbRVo46jqn8NQkM=; b=yyXawkMcNwWEob40iFN+ohcFhJ2AG4Q/i3AXuci2hcUcikuEVP8Z9wK5uDef77frbz uT/td6ljeyrxElaVqD3fX5zylghHrakv1Qbv22arAGzDG6hphqJZkZR66xCqnpylYTb5 J6VCKI8Qd17Yfe7SJYYXeyq8s3jBLRxptBnwDzUe78nDlQkhfk7BVOkBxuTLu6Po0N0A eDjjyub6rew8EBkZm4Xx+Fud5lGdcm6Q2gVvBMmkUBIfF1B+Hhlmfg45og+ZVaSb+NIi DvB1HkNOMo2jvhh7NIT660QLAN3I2qUmb2q/ae9DeyyAzQQNZQJ4yC6IYy1H15mQJGu2 4I7Q== 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 hg7-20020a1709072cc700b0079e1916c11asi6892284ejc.703.2022.10.23.22.56.38; Sun, 23 Oct 2022 22:57:06 -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 S230048AbiJXFms (ORCPT + 99 others); Mon, 24 Oct 2022 01:42:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49116 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230045AbiJXFml (ORCPT ); Mon, 24 Oct 2022 01:42:41 -0400 Received: from mail.nfschina.com (unknown [124.16.136.209]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2603A74E0A; Sun, 23 Oct 2022 22:42:40 -0700 (PDT) Received: from localhost (unknown [127.0.0.1]) by mail.nfschina.com (Postfix) with ESMTP id 302A51E80D74; Mon, 24 Oct 2022 13:41:11 +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 yJ82tyFT3FOp; Mon, 24 Oct 2022 13:41:08 +0800 (CST) Received: from localhost.localdomain (unknown [219.141.250.2]) (Authenticated sender: zeming@nfschina.com) by mail.nfschina.com (Postfix) with ESMTPA id 7CE4B1E80CA5; Mon, 24 Oct 2022 13:41:08 +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: checklist: Add malloc allocation judgment Date: Mon, 24 Oct 2022 13:42:22 +0800 Message-Id: <20221024054222.177899-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 list_item Only when the pointer judges that the pointer is valid can function code be executed. Signed-off-by: Li zeming --- scripts/kconfig/lxdialog/checklist.c | 45 ++++++++++++++-------------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/scripts/kconfig/lxdialog/checklist.c b/scripts/kconfig/lxdialog/checklist.c index fd161cfff121..61a8f86fe467 100644 --- a/scripts/kconfig/lxdialog/checklist.c +++ b/scripts/kconfig/lxdialog/checklist.c @@ -19,29 +19,30 @@ static void print_item(WINDOW * win, int choice, int selected) { int i; char *list_item = malloc(list_width + 1); + if (list_item) { + strncpy(list_item, item_str(), list_width - item_x); + list_item[list_width - item_x] = '\0'; - strncpy(list_item, item_str(), list_width - item_x); - list_item[list_width - item_x] = '\0'; - - /* Clear 'residue' of last item */ - wattrset(win, dlg.menubox.atr); - wmove(win, choice, 0); - for (i = 0; i < list_width; i++) - waddch(win, ' '); - - wmove(win, choice, check_x); - wattrset(win, selected ? dlg.check_selected.atr - : dlg.check.atr); - if (!item_is_tag(':')) - wprintw(win, "(%c)", item_is_tag('X') ? 'X' : ' '); - - wattrset(win, selected ? dlg.tag_selected.atr : dlg.tag.atr); - mvwaddch(win, choice, item_x, list_item[0]); - wattrset(win, selected ? dlg.item_selected.atr : dlg.item.atr); - waddstr(win, list_item + 1); - if (selected) { - wmove(win, choice, check_x + 1); - wrefresh(win); + /* Clear 'residue' of last item */ + wattrset(win, dlg.menubox.atr); + wmove(win, choice, 0); + for (i = 0; i < list_width; i++) + waddch(win, ' '); + + wmove(win, choice, check_x); + wattrset(win, selected ? dlg.check_selected.atr + : dlg.check.atr); + if (!item_is_tag(':')) + wprintw(win, "(%c)", item_is_tag('X') ? 'X' : ' '); + + wattrset(win, selected ? dlg.tag_selected.atr : dlg.tag.atr); + mvwaddch(win, choice, item_x, list_item[0]); + wattrset(win, selected ? dlg.item_selected.atr : dlg.item.atr); + waddstr(win, list_item + 1); + if (selected) { + wmove(win, choice, check_x + 1); + wrefresh(win); + } } free(list_item); } -- 2.18.2