mirror of
https://github.com/RGBCube/serenity
synced 2025-07-23 06:07:34 +00:00
Kernel: Make AnonymousFile::create API OOM safe
This commit is contained in:
parent
1580eeed98
commit
d2d6ab40f9
2 changed files with 4 additions and 2 deletions
|
@ -12,9 +12,9 @@ namespace Kernel {
|
||||||
|
|
||||||
class AnonymousFile final : public File {
|
class AnonymousFile final : public File {
|
||||||
public:
|
public:
|
||||||
static NonnullRefPtr<AnonymousFile> create(NonnullRefPtr<AnonymousVMObject> vmobject)
|
static RefPtr<AnonymousFile> create(NonnullRefPtr<AnonymousVMObject> vmobject)
|
||||||
{
|
{
|
||||||
return adopt_ref(*new AnonymousFile(move(vmobject)));
|
return adopt_ref_if_nonnull(new AnonymousFile(move(vmobject)));
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~AnonymousFile() override;
|
virtual ~AnonymousFile() override;
|
||||||
|
|
|
@ -30,6 +30,8 @@ KResultOr<int> Process::sys$anon_create(size_t size, int options)
|
||||||
return ENOMEM;
|
return ENOMEM;
|
||||||
|
|
||||||
auto anon_file = AnonymousFile::create(vmobject.release_nonnull());
|
auto anon_file = AnonymousFile::create(vmobject.release_nonnull());
|
||||||
|
if (!anon_file)
|
||||||
|
return ENOMEM;
|
||||||
auto description_or_error = FileDescription::create(*anon_file);
|
auto description_or_error = FileDescription::create(*anon_file);
|
||||||
if (description_or_error.is_error())
|
if (description_or_error.is_error())
|
||||||
return description_or_error.error();
|
return description_or_error.error();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue