fs: Fix nullptr check in GetFile

This commit is contained in:
TheTurtle 2024-07-15 16:52:24 +03:00 committed by GitHub
parent 3b0a5aed33
commit 0dda5eb6ef
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 6 additions and 2 deletions

View File

@ -132,8 +132,12 @@ File* HandleTable::GetFile(int d) {
}
File* HandleTable::GetFile(const std::filesystem::path& host_name) {
const auto it = std::ranges::find(m_files, host_name, &File::m_host_name);
return it == m_files.end() ? nullptr : *it;
for (auto* file : m_files) {
if (file != nullptr && file->m_host_name == host_name) {
return file;
}
}
return nullptr;
}
} // namespace Core::FileSys