(menu/cbs/menu_cbs_ok.c) Try to fix memory leak

This commit is contained in:
twinaphex 2016-06-19 22:28:55 +02:00
parent 096ca1851b
commit 8644e8e26b

View File

@ -633,6 +633,7 @@ static int action_ok_playlist_entry_collection(const char *path,
menu_content_ctx_playlist_info_t playlist_info; menu_content_ctx_playlist_info_t playlist_info;
size_t selection_ptr = 0; size_t selection_ptr = 0;
playlist_t *playlist = NULL; playlist_t *playlist = NULL;
bool playlist_initialized = false;
bool is_history = true; bool is_history = true;
const char *entry_path = NULL; const char *entry_path = NULL;
const char *entry_label = NULL; const char *entry_label = NULL;
@ -655,6 +656,7 @@ static int action_ok_playlist_entry_collection(const char *path,
if (!tmp_playlist) if (!tmp_playlist)
return menu_cbs_exit(); return menu_cbs_exit();
playlist_initialized = true;
} }
playlist = tmp_playlist; playlist = tmp_playlist;
@ -692,8 +694,13 @@ static int action_ok_playlist_entry_collection(const char *path,
found_associated_core = false; found_associated_core = false;
if (!found_associated_core) if (!found_associated_core)
return action_ok_file_load_with_detect_core(entry_path, {
int ret = action_ok_file_load_with_detect_core(entry_path,
label, type, selection_ptr, entry_idx); label, type, selection_ptr, entry_idx);
if (playlist_initialized)
playlist_free(tmp_playlist);
return ret;
}
menu_driver_ctl(RARCH_MENU_CTL_PLAYLIST_GET, &tmp_playlist); menu_driver_ctl(RARCH_MENU_CTL_PLAYLIST_GET, &tmp_playlist);