Fix 'Set Core Association' regression

This commit is contained in:
jdgleaver 2020-08-26 15:17:37 +01:00
parent df97af9b35
commit 7a07cc1305
5 changed files with 21 additions and 5 deletions

View File

@ -911,7 +911,7 @@ void core_info_get_name(const char *path, char *s, size_t len,
bool get_display_name)
{
size_t i;
struct string_list contents;
struct string_list contents = {0};
const char *path_basedir = !string_is_empty(path_info) ?
path_info : dir_cores;
const char *core_path_basename = path_basename(path);

View File

@ -64,6 +64,9 @@ bool dir_list_append(struct string_list *list, const char *dir, const char *ext,
struct string_list *dir_list_new(const char *dir, const char *ext,
bool include_dirs, bool include_hidden, bool include_compressed, bool recursive);
/* Warning: 'list' must zero initialised before
* calling this function, otherwise memory leaks/
* undefined behaviour will occur */
bool dir_list_initialize(struct string_list *list,
const char *dir,
const char *ext, bool include_dirs,

View File

@ -264,14 +264,17 @@ struct string_list *dir_list_new(const char *dir,
return list;
}
/* Warning: 'list' must zero initialised before
* calling this function, otherwise memory leaks/
* undefined behaviour will occur */
bool dir_list_initialize(struct string_list *list,
const char *dir,
const char *ext, bool include_dirs,
bool include_hidden, bool include_compressed,
bool recursive)
{
if (!list)
return NULL;
if (!list || !string_list_initialize(list))
return false;
return dir_list_append(list, dir, ext, include_dirs,
include_hidden, include_compressed, recursive);
}

View File

@ -168,8 +168,15 @@ bool string_list_append(struct string_list *list, const char *elem,
{
char *data_dup = NULL;
/* Note: If 'list' is incorrectly initialised
* (i.e. if struct is zero initialised and
* string_list_initialize() is not called on
* it) capacity will be zero. This will cause
* a segfault. Handle this case by forcing the new
* capacity to a fixed size of 32 */
if (list->size >= list->cap &&
!string_list_capacity(list, list->cap * 2))
!string_list_capacity(list,
(list->cap > 0) ? (list->cap * 2) : 32))
return false;
data_dup = strdup(elem);

View File

@ -4623,12 +4623,15 @@ static int action_ok_reset_core_association(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
menu_handle_t *menu = menu_driver_get_ptr();
size_t playlist_index;
if (!menu)
return menu_cbs_exit();
playlist_index = (size_t)menu->rpl_entry_selection_ptr;
if (!command_event(CMD_EVENT_RESET_CORE_ASSOCIATION,
(void *)&menu->rpl_entry_selection_ptr))
(void *)&playlist_index))
return menu_cbs_exit();
return 0;
}