diff --git a/AK/ByteBuffer.h b/AK/ByteBuffer.h index ee84e2091f..51227e0b71 100644 --- a/AK/ByteBuffer.h +++ b/AK/ByteBuffer.h @@ -27,6 +27,7 @@ public: return *this; } + static ByteBuffer createEmpty() { return ByteBuffer(Buffer::createUninitialized(0)); } static ByteBuffer createUninitialized(size_t size) { return ByteBuffer(Buffer::createUninitialized(size)); } static ByteBuffer copy(const byte* data, size_t size) { return ByteBuffer(Buffer::copy(data, size)); } static ByteBuffer wrap(byte* data, size_t size) { return ByteBuffer(Buffer::wrap(data, size)); } diff --git a/VirtualFileSystem/Ext2FileSystem.cpp b/VirtualFileSystem/Ext2FileSystem.cpp index 33ecbd6c3f..f8fb4f1732 100644 --- a/VirtualFileSystem/Ext2FileSystem.cpp +++ b/VirtualFileSystem/Ext2FileSystem.cpp @@ -260,6 +260,9 @@ ByteBuffer Ext2FileSystem::readInode(InodeIdentifier inode) const return nullptr; } + if (e2inode->i_size == 0) + return ByteBuffer::createEmpty(); + // Symbolic links shorter than 60 characters are store inline inside the i_block array. // This avoids wasting an entire block on short links. (Most links are short.) static const unsigned maxInlineSymlinkLength = 60;