summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Kernel/Net/LocalSocket.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/Kernel/Net/LocalSocket.cpp b/Kernel/Net/LocalSocket.cpp
index 5a38760c68..fe06dfe78c 100644
--- a/Kernel/Net/LocalSocket.cpp
+++ b/Kernel/Net/LocalSocket.cpp
@@ -33,12 +33,17 @@ void LocalSocket::for_each(Function<void(const LocalSocket&)> callback)
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)
{
- 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);
if (description1_result.is_error())