From c26f9d8dab4600a40c966f8143a89bb390135a52 Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Wed, 1 Oct 2025 17:02:46 -0700 Subject: [PATCH 1/2] =?UTF-8?q?fix=20memory=20corruption=20of=20'--script?= =?UTF-8?q?=3D=E2=80=A6'=20parameters?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CodeChecker says: [MEDIUM] clink/src/main.c:61:10: Potential leak of memory pointed to by 's' [unix.Malloc] while (true) { ^ [MEDIUM] clink/src/main.c:135:36: Use of memory after it is freed [unix.Malloc] realloc(option.script, strlen(option.script) + strlen(optarg) + 1… ^ Reported-by: CodeChecker 6.26.2 --- clink/src/main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/clink/src/main.c b/clink/src/main.c index 6ff6187d..9b5c45bf 100644 --- a/clink/src/main.c +++ b/clink/src/main.c @@ -138,6 +138,7 @@ static void parse_args(int argc, char **argv) { exit(EX_OSERR); } strcat(s, optarg); + option.script = s; } break; From a7bfbddd2c8a049afa02344dfb3cd9888108de43 Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Wed, 1 Oct 2025 17:02:46 -0700 Subject: [PATCH 2/2] fix: do not forget out of memory error during result highlighting CodeChecker says: [LOW] clink/src/ui.c:181:9: Value stored to 'rc' is never read [deadcode.DeadStores] rc = ENOMEM; ^ Reported-by: CodeChecker 6.26.2 --- clink/src/ui.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clink/src/ui.c b/clink/src/ui.c index f5976325..eae71cc7 100644 --- a/clink/src/ui.c +++ b/clink/src/ui.c @@ -179,7 +179,7 @@ static int format_results(clink_iter_t *it) { clink_symbol_t *r = realloc(results.rows, s * sizeof(results.rows[0])); if (UNLIKELY(r == NULL)) { rc = ENOMEM; - break; + goto done; } results.rows = r; results.size = s;