Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix game browser crash #3350

Merged
merged 1 commit into from
Feb 20, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/window_gamelist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,21 @@ bool Window_GameList::Refresh(FilesystemView filesystem_base, bool show_dotdot)

this->show_dotdot = show_dotdot;

auto files = base_fs.ListDirectory();
#ifndef USE_CUSTOM_FILEBUF
// Calling "Create" while iterating over the directory list appears to corrupt
// the file entries probably because of a reallocation due to caching new entries.
// Create a copy of the entries instead to workaround this issue.
DirectoryTree::DirectoryListType files = *base_fs.ListDirectory();
#else
DirectoryTree::DirectoryListType* files = base_fs.ListDirectory();
#endif

// Find valid game diectories
#ifndef USE_CUSTOM_FILEBUF
for (auto& dir : files) {
#else
for (auto& dir : *files) {
#endif
assert(!dir.second.name.empty() && "VFS BUG: Empty filename in the folder");

#ifdef EMSCRIPTEN
Expand Down
Loading