1
0
mirror of https://github.com/libretro/RetroArch synced 2024-07-08 12:15:49 +00:00

Explore: Fix freeing of cached playlist (it could cause a crash in glui menu when jumping up multiple menu lists)

Also makes setting cached_playlist with an external list less of a hack and simplifies menu_explore.c a bit
This commit is contained in:
Bernhard Schelling 2020-07-31 00:53:01 +09:00
parent e0ffe8184f
commit 5da2ada6b8
3 changed files with 14 additions and 20 deletions

View File

@ -486,8 +486,7 @@ static void explore_free(explore_state_t *state)
EX_BUF_FREE(state->entries);
for (i = 0; i != EX_BUF_LEN(state->playlists); i++)
if (state->playlists[i] != state->cached_playlist)
playlist_free(state->playlists[i]);
playlist_free(state->playlists[i]);
EX_BUF_FREE(state->playlists);
ex_arena_free(&state->arena);
}
@ -968,16 +967,6 @@ unsigned menu_displaylist_explore(file_list_t *list)
" '%s'", explore_state->find_string);
}
if (current_type == MENU_EXPLORE_TAB)
{
/* free any existing playlist
* when entering the explore view */
playlist_free_cached();
}
playlist_set_cached(NULL);
explore_state->cached_playlist = NULL;
if ( current_type == MENU_EXPLORE_TAB
|| current_type == EXPLORE_TYPE_ADDITIONALFILTER)
{
@ -1218,8 +1207,7 @@ SKIP_ENTRY:;
/* Fake all the state so the content screen
* and information screen think we're viewing via playlist */
playlist_set_cached(pl);
explore_state->cached_playlist = pl;
playlist_set_cached_external(pl);
menu->rpl_entry_selection_ptr = (pl_entry - pl_first);
strlcpy(menu->deferred_path,
pl_entry->path, sizeof(menu->deferred_path));

View File

@ -56,6 +56,7 @@ struct content_playlist
bool modified;
bool old_format;
bool compressed;
bool cached_external;
enum playlist_label_display_mode label_display_mode;
enum playlist_thumbnail_mode right_thumbnail_mode;
@ -107,9 +108,11 @@ typedef int (playlist_sort_fun_t)(
/* TODO/FIXME - hack for allowing the explore view to switch
* over to a playlist item */
void playlist_set_cached(playlist_t* pl)
void playlist_set_cached_external(playlist_t* pl)
{
playlist_free_cached();
playlist_cached = pl;
playlist_cached->cached_external = true;
}
/* Convenience function: copies specified playlist
@ -1386,9 +1389,10 @@ void playlist_write_runtime_file(playlist_t *playlist)
JSON_Writer_WriteNewLine(context.writer);
JSON_Writer_Free(context.writer);
playlist->modified = false;
playlist->old_format = false;
playlist->compressed = false;
playlist->modified = false;
playlist->old_format = false;
playlist->compressed = false;
playlist->cached_external = false;
RARCH_LOG("[Playlist]: Written to playlist file: %s\n", playlist->config.path);
end:
@ -2609,7 +2613,8 @@ end:
void playlist_free_cached(void)
{
playlist_free(playlist_cached);
if (playlist_cached && !playlist_cached->cached_external)
playlist_free(playlist_cached);
playlist_cached = NULL;
}
@ -2668,6 +2673,7 @@ playlist_t *playlist_init(const playlist_config_t *config)
playlist->modified = false;
playlist->old_format = false;
playlist->compressed = false;
playlist->cached_external = false;
playlist->size = 0;
playlist->default_core_name = NULL;
playlist->default_core_path = NULL;

View File

@ -351,7 +351,7 @@ core_info_t *playlist_entry_get_core_info(const struct playlist_entry* entry);
* default core association */
core_info_t *playlist_get_default_core_info(playlist_t* playlist);
void playlist_set_cached(playlist_t* pl);
void playlist_set_cached_external(playlist_t* pl);
RETRO_END_DECLS