mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-23 17:52:26 -05:00
Kernel: Make PTYMultiplexer::open API OOM safe
This commit is contained in:
parent
f3f5a225b9
commit
77868abe6a
Notes:
sideshowbarker
2024-07-18 18:07:33 +09:00
Author: https://github.com/bgianfo Commit: https://github.com/SerenityOS/serenity/commit/77868abe6a6 Pull-request: https://github.com/SerenityOS/serenity/pull/7103 Reviewed-by: https://github.com/awesomekling
1 changed files with 4 additions and 2 deletions
|
@ -40,9 +40,11 @@ KResultOr<NonnullRefPtr<FileDescription>> PTYMultiplexer::open(int options)
|
|||
if (m_freelist.is_empty())
|
||||
return EBUSY;
|
||||
auto master_index = m_freelist.take_last();
|
||||
auto master = adopt_ref(*new MasterPTY(master_index));
|
||||
auto master = adopt_ref_if_nonnull(new MasterPTY(master_index));
|
||||
if (!master)
|
||||
return ENOMEM;
|
||||
dbgln_if(PTMX_DEBUG, "PTYMultiplexer::open: Vending master {}", master->index());
|
||||
auto description = FileDescription::create(move(master));
|
||||
auto description = FileDescription::create(*master);
|
||||
if (!description.is_error()) {
|
||||
description.value()->set_rw_mode(options);
|
||||
description.value()->set_file_flags(options);
|
||||
|
|
Loading…
Add table
Reference in a new issue