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.
This commit is contained in:
Stephen Seo 2024-06-27 13:28:53 +09:00
parent 44080e85cc
commit 21752fb504

View file

@ -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;