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
This commit is contained in:
Erik Abair
2026-03-11 12:02:54 -07:00
committed by GitHub
parent 9e70c5c325
commit 1425a8c39b
+4
View File
@@ -70,6 +70,10 @@ static std::string NormalizeDefaultLocation(const char *default_location)
if (std::filesystem::is_directory(path)) {
return (path / "").string();
}
// Prevent a crash in SDL3 file dialog
if (!std::filesystem::exists(path)) {
return {};
}
#endif
} catch (...) {
// Fall through to return original path