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:
parent
112393b38a
commit
11bd2002bb
1 changed files with 5 additions and 2 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue