From 358d20687f6913f151f3943e1d8655ce71457f6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= Date: Sat, 19 Dec 2020 23:05:07 +0100 Subject: [PATCH] Use variable-length-array instead of small dynamic allocation --- CommandScreen.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CommandScreen.c b/CommandScreen.c index d3428290..56b752d6 100644 --- a/CommandScreen.c +++ b/CommandScreen.c @@ -17,9 +17,10 @@ static void CommandScreen_scan(InfoScreen* this) { Panel_prune(panel); const char* p = Process_getCommand(this->process); - char* line = xMalloc(COLS + 1); + char line[COLS + 1]; int line_offset = 0, last_spc = -1, len; for (; *p != '\0'; p++, line_offset++) { + assert(line_offset >= 0 && (size_t)line_offset < sizeof(line)); line[line_offset] = *p; if (*p == ' ') { last_spc = line_offset; @@ -41,7 +42,6 @@ static void CommandScreen_scan(InfoScreen* this) { InfoScreen_addLine(this, line); } - free(line); Panel_setSelected(panel, idx); }