mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-02 06:09:08 +00:00
Kernel: Make LocalSocket factory APIs OOM safe
This commit is contained in:
parent
51ceb172b9
commit
9375f3dc09
Notes:
sideshowbarker
2024-07-18 18:14:40 +09:00
Author: https://github.com/bgianfo
Commit: 9375f3dc09
Pull-request: https://github.com/SerenityOS/serenity/pull/7077
1 changed files with 7 additions and 2 deletions
|
@ -33,12 +33,17 @@ void LocalSocket::for_each(Function<void(const LocalSocket&)> callback)
|
||||||
|
|
||||||
KResultOr<NonnullRefPtr<Socket>> LocalSocket::create(int type)
|
KResultOr<NonnullRefPtr<Socket>> LocalSocket::create(int type)
|
||||||
{
|
{
|
||||||
return adopt_ref(*new LocalSocket(type));
|
auto socket = adopt_ref_if_nonnull(new LocalSocket(type));
|
||||||
|
if (socket)
|
||||||
|
return socket.release_nonnull();
|
||||||
|
return ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
KResultOr<SocketPair> LocalSocket::create_connected_pair(int type)
|
KResultOr<SocketPair> LocalSocket::create_connected_pair(int type)
|
||||||
{
|
{
|
||||||
auto socket = adopt_ref(*new LocalSocket(type));
|
auto socket = adopt_ref_if_nonnull(new LocalSocket(type));
|
||||||
|
if (!socket)
|
||||||
|
return ENOMEM;
|
||||||
|
|
||||||
auto description1_result = FileDescription::create(*socket);
|
auto description1_result = FileDescription::create(*socket);
|
||||||
if (description1_result.is_error())
|
if (description1_result.is_error())
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue