From: Stephen Seo Date: Thu, 27 Jun 2024 04:28:53 +0000 (+0900) Subject: Fix invalid memory usage bug causing invalid free X-Git-Tag: 1.0~111 X-Git-Url: https://git.seodisparate.com/gitweb?a=commitdiff_plain;h=21752fb504045a710092db092573d12155ead71d;p=SimpleArchiver 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. --- 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;