diff --git a/menu/cbs/menu_cbs_info.c b/menu/cbs/menu_cbs_info.c index 213ac38d60..076818b8bf 100644 --- a/menu/cbs/menu_cbs_info.c +++ b/menu/cbs/menu_cbs_info.c @@ -41,9 +41,8 @@ static int action_info_default(unsigned type, const char *label) info.list = menu_stack; info.directory_ptr = selection; info.enum_idx = MENU_ENUM_LABEL_INFO_SCREEN; - strlcpy(info.label, - msg_hash_to_str(MENU_ENUM_LABEL_INFO_SCREEN), - sizeof(info.label)); + info.label = strdup( + msg_hash_to_str(MENU_ENUM_LABEL_INFO_SCREEN)); if (!menu_displaylist_ctl(DISPLAYLIST_HELP, &info)) goto error; diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index e336eca9a2..be0015243b 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -875,7 +875,7 @@ int generic_action_ok_displaylist_push(const char *path, } if (info_label) - strlcpy(info.label, info_label, sizeof(info.label)); + info.label = strdup(info_label); if (info_path) strlcpy(info.path, info_path, sizeof(info.path)); diff --git a/menu/drivers/menu_generic.c b/menu/drivers/menu_generic.c index ce8a61e5d4..39b25f678e 100644 --- a/menu/drivers/menu_generic.c +++ b/menu/drivers/menu_generic.c @@ -266,8 +266,8 @@ bool generic_menu_init_list(void *data) menu_displaylist_info_init(&info); - strlcpy(info.label, - msg_hash_to_str(MENU_ENUM_LABEL_MAIN_MENU), sizeof(info.label)); + info.label = strdup( + msg_hash_to_str(MENU_ENUM_LABEL_MAIN_MENU)); info.enum_idx = MENU_ENUM_LABEL_MAIN_MENU; menu_entries_append_enum(menu_stack, info.path, diff --git a/menu/drivers/nuklear.c b/menu/drivers/nuklear.c index 433944c768..d863556794 100644 --- a/menu/drivers/nuklear.c +++ b/menu/drivers/nuklear.c @@ -464,8 +464,8 @@ static bool nk_menu_init_list(void *data) menu_displaylist_info_init(&info); - strlcpy(info.label, - msg_hash_to_str(MENU_ENUM_LABEL_HISTORY_TAB), sizeof(info.label)); + info.label = strdup( + msg_hash_to_str(MENU_ENUM_LABEL_HISTORY_TAB)); info.enum_idx = MENU_ENUM_LABEL_HISTORY_TAB; menu_entries_append_enum(menu_stack, diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index d9e46a4bc7..ddd6b2fa09 100755 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -1861,10 +1861,9 @@ static void xmb_init_horizontal_list(xmb_handle_t *xmb) info.list = xmb->horizontal_list; strlcpy(info.path, settings->paths.directory_playlist, sizeof(info.path)); - strlcpy(info.label, - msg_hash_to_str(MENU_ENUM_LABEL_CONTENT_COLLECTION_LIST), - sizeof(info.label)); + info.label = strdup( + msg_hash_to_str(MENU_ENUM_LABEL_CONTENT_COLLECTION_LIST)); info.exts = strdup( file_path_str(FILE_PATH_LPL_EXTENSION_NO_DOT)); info.type_default = FILE_TYPE_PLAIN; @@ -4377,8 +4376,8 @@ static bool xmb_menu_init_list(void *data) menu_displaylist_info_init(&info); - strlcpy(info.label, - msg_hash_to_str(MENU_ENUM_LABEL_MAIN_MENU), sizeof(info.label)); + info.label = strdup( + msg_hash_to_str(MENU_ENUM_LABEL_MAIN_MENU)); info.exts = strdup(file_path_str(FILE_PATH_LPL_EXTENSION_NO_DOT)); info.type_default = FILE_TYPE_PLAIN; diff --git a/menu/drivers/zarch.c b/menu/drivers/zarch.c index 9ee54f4097..036d07fb8f 100644 --- a/menu/drivers/zarch.c +++ b/menu/drivers/zarch.c @@ -1130,8 +1130,8 @@ static bool zarch_menu_init_list(void *data) menu_displaylist_info_free(&info); - strlcpy(info.label, - msg_hash_to_str(MENU_ENUM_LABEL_HISTORY_TAB), sizeof(info.label)); + info.label = strdup( + msg_hash_to_str(MENU_ENUM_LABEL_HISTORY_TAB)); info.enum_idx = MENU_ENUM_LABEL_HISTORY_TAB; menu_entries_append_enum(menu_stack, diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index abc3be0e43..54ec402b66 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -3992,12 +3992,13 @@ static bool menu_displaylist_push_internal( if (info->exts && !string_is_empty(info->exts)) free(info->exts); + if (info->label && !string_is_empty(info->label)) + free(info->label); - info->exts = strdup( + info->exts = strdup( file_path_str(FILE_PATH_LPL_EXTENSION_NO_DOT)); - strlcpy(info->label, - msg_hash_to_str(MENU_ENUM_LABEL_CONTENT_COLLECTION_LIST), - sizeof(info->label)); + info->label = strdup( + msg_hash_to_str(MENU_ENUM_LABEL_CONTENT_COLLECTION_LIST)); menu_entries_ctl(MENU_ENTRIES_CTL_CLEAR, info->list); menu_displaylist_ctl(DISPLAYLIST_MUSIC_HISTORY, info); @@ -4010,11 +4011,13 @@ static bool menu_displaylist_push_internal( if (info->exts && !string_is_empty(info->exts)) free(info->exts); - info->exts = strdup( + if (info->label && !string_is_empty(info->label)) + free(info->label); + + info->exts = strdup( file_path_str(FILE_PATH_LPL_EXTENSION_NO_DOT)); - strlcpy(info->label, - msg_hash_to_str(MENU_ENUM_LABEL_CONTENT_COLLECTION_LIST), - sizeof(info->label)); + info->label = strdup( + msg_hash_to_str(MENU_ENUM_LABEL_CONTENT_COLLECTION_LIST)); menu_entries_ctl(MENU_ENTRIES_CTL_CLEAR, info->list); menu_displaylist_ctl(DISPLAYLIST_VIDEO_HISTORY, info); @@ -4027,11 +4030,13 @@ static bool menu_displaylist_push_internal( if (info->exts && !string_is_empty(info->exts)) free(info->exts); - info->exts = strdup( + if (info->label && !string_is_empty(info->label)) + free(info->label); + + info->exts = strdup( file_path_str(FILE_PATH_LPL_EXTENSION_NO_DOT)); - strlcpy(info->label, - msg_hash_to_str(MENU_ENUM_LABEL_CONTENT_COLLECTION_LIST), - sizeof(info->label)); + info->label = strdup( + msg_hash_to_str(MENU_ENUM_LABEL_CONTENT_COLLECTION_LIST)); menu_entries_ctl(MENU_ENTRIES_CTL_CLEAR, info->list); @@ -4064,11 +4069,13 @@ static bool menu_displaylist_push_internal( if (info->exts && !string_is_empty(info->exts)) free(info->exts); + if (info->label && !string_is_empty(info->label)) + free(info->label); + info->exts = strdup( file_path_str(FILE_PATH_LPL_EXTENSION_NO_DOT)); - strlcpy(info->label, - msg_hash_to_str(MENU_ENUM_LABEL_CONTENT_COLLECTION_LIST), - sizeof(info->label)); + info->label = strdup( + msg_hash_to_str(MENU_ENUM_LABEL_CONTENT_COLLECTION_LIST)); if (string_is_empty(settings->paths.directory_playlist)) { @@ -4141,10 +4148,10 @@ bool menu_displaylist_push(menu_displaylist_ctx_entry_t *entry) strlcpy(info.path, path, sizeof(info.path)); if (!string_is_empty(label)) - strlcpy(info.label, label, sizeof(info.label)); + info.label = strdup(label); if (!info.list) - return false; + goto error; if (menu_displaylist_push_internal(label, entry, &info)) return menu_displaylist_process(&info); @@ -4154,10 +4161,15 @@ bool menu_displaylist_push(menu_displaylist_ctx_entry_t *entry) if (cbs && cbs->action_deferred_push) { if (cbs->action_deferred_push(&info) != 0) - return -1; + goto error; } return true; + +error: + if (info.label) + free(info.label); + return false; } static void menu_displaylist_parse_playlist_history( @@ -4317,16 +4329,16 @@ void menu_displaylist_info_free(menu_displaylist_info_t *info) free(info->path_b); if (info->path_c) free(info->path_c); + if (info->label) + free(info->label); info->exts = NULL; info->path_b = NULL; info->path_c = NULL; + info->label = NULL; #if 0 if (info->path) free(info->path); - if (info->label) - free(info->label); info->path = NULL; - info->label = NULL; #endif } @@ -4345,12 +4357,12 @@ void menu_displaylist_info_init(menu_displaylist_info_t *info) info->download_core = false; info->need_navigation_clear = false; info->path[0] = '\0'; - info->label[0] = '\0'; info->type = 0; info->type_default = 0; info->flags = 0; info->label_hash = 0; info->directory_ptr = 0; + info->label = NULL; info->path_b = NULL; info->path_c = NULL; info->exts = NULL; @@ -4439,8 +4451,11 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, void *data) strlcpy(info->path_b, str_list->elems[1].data, sizeof(info->path_b)); - strlcpy(info->label, - str_list->elems[0].data, sizeof(info->label)); + + if (info->label && !string_is_empty(info->label)) + free(info->label); + + info->label = strdup(str_list->elems[0].data); string_list_free(str_list); } diff --git a/menu/menu_displaylist.h b/menu/menu_displaylist.h index 4dcfc0c411..2a12c9161f 100644 --- a/menu/menu_displaylist.h +++ b/menu/menu_displaylist.h @@ -188,7 +188,7 @@ typedef struct menu_displaylist_info char *path_b; char *path_c; char *exts; - char label[255]; + char *label; unsigned type; unsigned type_default; unsigned flags; diff --git a/menu/menu_setting.c b/menu/menu_setting.c index 552618fe70..a758531152 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -770,7 +770,7 @@ int menu_action_handle_setting(rarch_setting_t *setting, menu_displaylist_info_init(&info); strlcpy(info.path, setting->default_value.string, sizeof(info.path)); - strlcpy(info.label, name, sizeof(info.label)); + info.label = strdup(name); info.type = type; info.directory_ptr = selection; info.list = menu_stack; @@ -1674,9 +1674,8 @@ void general_write_handler(void *data) menu_displaylist_info_init(&info); info.enum_idx = MENU_ENUM_LABEL_HELP; - strlcpy(info.label, - msg_hash_to_str(MENU_ENUM_LABEL_HELP), - sizeof(info.label)); + info.label = strdup( + msg_hash_to_str(MENU_ENUM_LABEL_HELP)); info.list = menu_stack; if (menu_displaylist_ctl(DISPLAYLIST_GENERIC, &info)) diff --git a/menu/widgets/menu_dialog.c b/menu/widgets/menu_dialog.c index b0710b5673..4e4ecb065b 100644 --- a/menu/widgets/menu_dialog.c +++ b/menu/widgets/menu_dialog.c @@ -263,10 +263,8 @@ void menu_dialog_push(void) info.list = menu_entries_get_menu_stack_ptr(0); info.enum_idx = MENU_ENUM_LABEL_HELP; - - strlcpy(info.label, - msg_hash_to_str(MENU_ENUM_LABEL_HELP), - sizeof(info.label)); + info.label = strdup( + msg_hash_to_str(MENU_ENUM_LABEL_HELP)); menu_displaylist_ctl(DISPLAYLIST_HELP, &info); } diff --git a/menu/widgets/menu_input_bind_dialog.c b/menu/widgets/menu_input_bind_dialog.c index 025e94166f..960110fcb8 100644 --- a/menu/widgets/menu_input_bind_dialog.c +++ b/menu/widgets/menu_input_bind_dialog.c @@ -110,8 +110,8 @@ static int menu_input_key_bind_set_mode_common( info.type = MENU_SETTINGS_CUSTOM_BIND_KEYBOARD; info.directory_ptr = selection; info.enum_idx = MENU_ENUM_LABEL_CUSTOM_BIND; - strlcpy(info.label, - msg_hash_to_str(MENU_ENUM_LABEL_CUSTOM_BIND), sizeof(info.label)); + info.label = strdup( + msg_hash_to_str(MENU_ENUM_LABEL_CUSTOM_BIND)); if (menu_displaylist_ctl(DISPLAYLIST_INFO, &info)) menu_displaylist_process(&info); menu_displaylist_info_free(&info); @@ -125,9 +125,8 @@ static int menu_input_key_bind_set_mode_common( info.type = MENU_SETTINGS_CUSTOM_BIND_KEYBOARD; info.directory_ptr = selection; info.enum_idx = MENU_ENUM_LABEL_CUSTOM_BIND_ALL; - strlcpy(info.label, - msg_hash_to_str(MENU_ENUM_LABEL_CUSTOM_BIND_ALL), - sizeof(info.label)); + info.label = strdup( + msg_hash_to_str(MENU_ENUM_LABEL_CUSTOM_BIND_ALL)); if (menu_displaylist_ctl(DISPLAYLIST_INFO, &info)) menu_displaylist_process(&info);