Merge pull request #12368 from jdgleaver/core-info-fix

This commit is contained in:
Autechre 2021-05-07 14:28:18 +02:00 committed by GitHub
commit 53a266728b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1233,19 +1233,25 @@ static void core_info_path_list_free(core_path_list_t *path_list)
}
static core_path_list_t *core_info_path_list_new(const char *core_dir,
const char *core_ext, bool show_hidden_files)
const char *core_exts, bool show_hidden_files)
{
core_path_list_t *path_list = (core_path_list_t*)calloc(1, sizeof(*path_list));
bool dir_list_ok = false;
core_path_list_t *path_list = (core_path_list_t*)
calloc(1, sizeof(*path_list));
struct string_list *core_ext_list = NULL;
bool dir_list_ok = false;
char exts[32];
size_t i;
exts[0] = '\0';
if (string_is_empty(core_ext) ||
if (string_is_empty(core_exts) ||
!path_list)
goto error;
core_ext_list = string_split(core_exts, "|");
if (!core_ext_list)
goto error;
/* Allocate list containers */
path_list->dir_list = string_list_new();
path_list->core_list = (core_file_path_list_t*)calloc(1,
@ -1260,7 +1266,7 @@ static core_path_list_t *core_info_path_list_new(const char *core_dir,
/* Get list of file extensions to include
* (core + lock file) */
fill_pathname_join_delim(exts, core_ext, FILE_PATH_LOCK_EXTENSION_NO_DOT,
fill_pathname_join_delim(exts, core_exts, FILE_PATH_LOCK_EXTENSION_NO_DOT,
'|', sizeof(exts));
/* Fetch core directory listing */
@ -1314,7 +1320,7 @@ static core_path_list_t *core_info_path_list_new(const char *core_dir,
continue;
/* Check whether this is a core or lock file */
if (string_is_equal(file_ext, core_ext))
if (string_list_find_elem(core_ext_list, file_ext))
{
path_list->core_list->list[
path_list->core_list->size].path = file_path;
@ -1332,9 +1338,11 @@ static core_path_list_t *core_info_path_list_new(const char *core_dir,
}
}
string_list_free(core_ext_list);
return path_list;
error:
string_list_free(core_ext_list);
core_info_path_list_free(path_list);
return NULL;
}