From 7e890def481367694e2078dec21d2d9160e9fb77 Mon Sep 17 00:00:00 2001 From: squidbus <175574877+squidbus@users.noreply.github.com> Date: Sat, 21 Dec 2024 16:49:34 -0800 Subject: [PATCH] fs: Return nullptr when file descriptor is out of bounds. (#1842) --- src/core/file_sys/fs.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/core/file_sys/fs.cpp b/src/core/file_sys/fs.cpp index 45ba67b9..bf340e9e 100644 --- a/src/core/file_sys/fs.cpp +++ b/src/core/file_sys/fs.cpp @@ -171,6 +171,9 @@ void HandleTable::DeleteHandle(int d) { File* HandleTable::GetFile(int d) { std::scoped_lock lock{m_mutex}; + if (d < 0 || d >= m_files.size()) { + return nullptr; + } return m_files.at(d); }