Skip to content

Commit

Permalink
[dxvk] Work around locale-dependent regex parsing crash
Browse files Browse the repository at this point in the history
  • Loading branch information
doitsujin committed Feb 2, 2025
1 parent 5569274 commit f3f42ee
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/util/config/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1214,8 +1214,15 @@ namespace dxvk {
const Config* findProfile(const ProfileList& profiles, const std::string& appName) {
auto appConfig = std::find_if(profiles.begin(), profiles.end(),
[&appName] (const std::pair<const char*, Config>& pair) {
std::regex expr(pair.first, std::regex::extended | std::regex::icase);
return std::regex_search(appName, expr);
// With certain locales, regex parsing will simply crash. Using regex::imbue
// does not resolve this; only the global locale seems to matter here. Catch
// bad_alloc errors to work around this for now.
try {
std::regex expr(pair.first, std::regex::extended | std::regex::icase);
return std::regex_search(appName, expr);
} catch (const std::bad_alloc& e) {
return false;
}
});

return appConfig != profiles.end()
Expand Down

0 comments on commit f3f42ee

Please sign in to comment.