mirror of
https://github.com/xemu-project/xemu.git
synced 2026-07-11 01:24:41 +02:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user