mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-28 11:49:44 +00:00
Kernel: Make InodeFile::create() API OOM safe
This commit is contained in:
parent
112393b38a
commit
11bd2002bb
Notes:
sideshowbarker
2024-07-18 18:15:52 +09:00
Author: https://github.com/bgianfo
Commit: 11bd2002bb
Pull-request: https://github.com/SerenityOS/serenity/pull/7026
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