Skip to content

Commit 4493b1a

Browse files
author
fdelapena
authored
Merge pull request #3350 from Ghabry/fix-gamebrowser-crash
Fix game browser crash
2 parents 16a5258 + 07c6630 commit 4493b1a

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/window_gamelist.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,21 @@ bool Window_GameList::Refresh(FilesystemView filesystem_base, bool show_dotdot)
3737

3838
this->show_dotdot = show_dotdot;
3939

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

4249
// Find valid game diectories
50+
#ifndef USE_CUSTOM_FILEBUF
51+
for (auto& dir : files) {
52+
#else
4353
for (auto& dir : *files) {
54+
#endif
4455
assert(!dir.second.name.empty() && "VFS BUG: Empty filename in the folder");
4556

4657
#ifdef EMSCRIPTEN

0 commit comments

Comments
 (0)