Added space reservation
This commit is contained in:
@@ -202,6 +202,7 @@ result_t execute(int* _exit_code, char** _stdoutbuf, char** _stderrbuf, const ch
|
||||
va_start(args, executable);
|
||||
|
||||
for (int i = 1; i < argc; i++) {
|
||||
errno = 0;
|
||||
argv[i] = strdup(va_arg(args, const char*));
|
||||
if (argv[i] == NULL) {
|
||||
for (int j = 0; j < i; j++)
|
||||
@@ -511,13 +512,14 @@ result_t list_files(char*** _files, const char* path, bool (*filter)(const char*
|
||||
continue;
|
||||
|
||||
// Add the entry to the files array
|
||||
errno = 0;
|
||||
files[length] = strdup(entry->d_name);
|
||||
if (files[length] == NULL) {
|
||||
for (size_t i = 0; i < length; i++)
|
||||
free(files[i]);
|
||||
free(files);
|
||||
closedir(dir);
|
||||
return failure("Failed to allocate memory for the file name.");
|
||||
return failure("Failed to allocate memory for the file name (%s).", strerror(errno));
|
||||
}
|
||||
|
||||
length++;
|
||||
|
Reference in New Issue
Block a user