Fix resource leak

This commit is contained in:
twinaphex 2017-09-12 05:08:56 +02:00
parent c1f60c1aa6
commit 2d4cd1bd0e

View File

@ -1034,8 +1034,6 @@ static int file_load_with_detect_core_wrapper(
unsigned type, bool is_carchive)
{
menu_content_ctx_defer_info_t def_info;
char menu_path_new[PATH_MAX_LENGTH];
char *new_core_path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
int ret = 0;
const char *menu_path = NULL;
const char *menu_label = NULL;
@ -1045,21 +1043,24 @@ static int file_load_with_detect_core_wrapper(
if (!menu_driver_ctl(RARCH_MENU_CTL_DRIVER_DATA_GET, &menu))
return menu_cbs_exit();
{
char *menu_path_new = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
char *new_core_path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
new_core_path[0] = menu_path_new[0] = '\0';
menu_entries_get_last_stack(&menu_path, &menu_label, NULL, &enum_idx, NULL);
if (!string_is_empty(menu_path))
strlcpy(menu_path_new, menu_path, sizeof(menu_path_new));
strlcpy(menu_path_new, menu_path, PATH_MAX_LENGTH * sizeof(char));
if (string_is_equal(menu_label,
msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_ARCHIVE_OPEN_DETECT_CORE)))
fill_pathname_join(menu_path_new, menu->scratch2_buf, menu->scratch_buf,
sizeof(menu_path_new));
PATH_MAX_LENGTH * sizeof(char));
else if (string_is_equal(menu_label,
msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_ARCHIVE_OPEN)))
fill_pathname_join(menu_path_new, menu->scratch2_buf, menu->scratch_buf,
sizeof(menu_path_new));
PATH_MAX_LENGTH * sizeof(char));
core_info_get_list(&list);
@ -1078,9 +1079,12 @@ static int file_load_with_detect_core_wrapper(
if ( !is_carchive && !string_is_empty(path)
&& !string_is_empty(menu_path_new))
fill_pathname_join(detect_content_path, menu_path_new, path,
fill_pathname_join(detect_content_path,
menu_path_new, path,
sizeof(detect_content_path));
free(menu_path_new);
if (enum_label_idx == MENU_ENUM_LABEL_COLLECTION)
return generic_action_ok_displaylist_push(path, NULL,
NULL, 0, idx, entry_idx, ACTION_OK_DL_DEFERRED_CORE_LIST_SET);
@ -1111,6 +1115,7 @@ static int file_load_with_detect_core_wrapper(
default:
break;
}
}
return ret;
}