From 21752fb504045a710092db092573d12155ead71d Mon Sep 17 00:00:00 2001 From: Stephen Seo Date: Thu, 27 Jun 2024 13:28:53 +0900 Subject: [PATCH] Fix invalid memory usage bug causing invalid free realloc(...) was not used propertly. The number of items to be reallocated was specified, but not the size of each item. --- src/parser.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/parser.c b/src/parser.c index 28883d2..2e944a4 100644 --- a/src/parser.c +++ b/src/parser.c @@ -116,7 +116,7 @@ int simple_archiver_parse_args(int argc, const char **argv, // TODO verify this is necessary, using different variables. ptr = out->working_files; - out->working_files = realloc(ptr, working_size + 1); + out->working_files = realloc(ptr, sizeof(char*) * (working_size + 1)); // Set new actual last element to NULL. out->working_files[working_size] = NULL;