Skip to content

Commit 1425a8c

Browse files
authored
ui: Do not pass missing paths to SDL_ShowOpenFileDialog
Passing two levels of invalid paths to `SDL_ShowOpenFileDialog` on Windows causes a crash. E.g., given a directory `d:\foo` that exists, passing `D:\foo\bar\baz` will trigger the crash. In this case, the `FileDialogCallbackWrapper` callback is invoked twice, leading to a double-free. Fixes #2785
1 parent 9e70c5c commit 1425a8c

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

ui/xui/misc.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ static std::string NormalizeDefaultLocation(const char *default_location)
7070
if (std::filesystem::is_directory(path)) {
7171
return (path / "").string();
7272
}
73+
// Prevent a crash in SDL3 file dialog
74+
if (!std::filesystem::exists(path)) {
75+
return {};
76+
}
7377
#endif
7478
} catch (...) {
7579
// Fall through to return original path

0 commit comments

Comments
 (0)