kernel/ext2: Make sure we don't crash when accessing the last inode
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
apio 2023-07-02 17:30:14 +02:00
parent f0a7098470
commit d363d5e915
Signed by: apio
GPG Key ID: B8A7D06E42258954

View File

@ -27,7 +27,8 @@ namespace Ext2
Result<SharedPtr<VFS::Inode>> FileSystem::find_inode_by_number(ino_t inum, bool initialize_dir_now) Result<SharedPtr<VFS::Inode>> FileSystem::find_inode_by_number(ino_t inum, bool initialize_dir_now)
{ {
check(inum < m_superblock.nr_inodes); // Inode numbers start at 1.
check(inum <= m_superblock.nr_inodes);
auto maybe_inode = m_inode_cache.try_get(inum); auto maybe_inode = m_inode_cache.try_get(inum);
if (maybe_inode.has_value()) return maybe_inode.value(); if (maybe_inode.has_value()) return maybe_inode.value();