[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20221024054222.177899-1-zeming@nfschina.com>
Date: Mon, 24 Oct 2022 13:42:22 +0800
From: Li zeming <zeming@...china.com>
To: masahiroy@...nel.org
Cc: linux-kbuild@...r.kernel.org, linux-kernel@...r.kernel.org,
Li zeming <zeming@...china.com>
Subject: [PATCH] lxdialog: checklist: Add malloc allocation judgment
Add list_item Only when the pointer judges that the pointer is valid
can function code be executed.
Signed-off-by: Li zeming <zeming@...china.com>
---
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
Powered by blists - more mailing lists