1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 05:58:11 +00:00

Kernel: Make InodeFile::create() API OOM safe

This commit is contained in:
Brian Gianforcaro 2021-05-11 03:54:44 -07:00 committed by Andreas Kling
parent 112393b38a
commit 11bd2002bb

View file

@ -14,9 +14,12 @@ class Inode;
class InodeFile final : public File {
public:
static NonnullRefPtr<InodeFile> create(NonnullRefPtr<Inode>&& inode)
static KResultOr<NonnullRefPtr<InodeFile>> create(NonnullRefPtr<Inode>&& inode)
{
return adopt_ref(*new InodeFile(move(inode)));
auto file = adopt_ref_if_nonnull(new InodeFile(move(inode)));
if (!file)
return ENOMEM;
return file.release_nonnull();
}
virtual ~InodeFile() override;