EmulatedFiles: Don't crash on too long paths

This commit is contained in:
Stefanos Kornilios Mitsis Poiitidis committed 2020-09-12 00:53:39 +03:00
1 parent ad13c82918
commit abcdff6a50
1 file changed
+6 -1
@@ -612,7 +612,12 @@ namespace FEXCore::EmulatedFile {
}
int32_t EmulatedFDManager::OpenAt(int dirfs, const char *pathname, int flags, uint32_t mode) {
string cpath = std::filesystem::exists(pathname) ? std::filesystem::canonical(pathname)
std::error_code ec;
bool exists = std::filesystem::exists(pathname, ec);
if (ec) {
return -1;
}
string cpath = exists ? std::filesystem::canonical(pathname)
: std::filesystem::path(pathname).lexically_normal(); // *Note: this doesn't transform to absolute
if (EmulatedMap.find(cpath) == EmulatedMap.end()) {