mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 05:18:12 +00:00
Kernel: Make UDPSocket::create() API OOM safe
This commit is contained in:
parent
858fff979a
commit
2e34714ba1
3 changed files with 13 additions and 5 deletions
|
@ -54,9 +54,12 @@ UDPSocket::~UDPSocket()
|
|||
sockets_by_port().resource().remove(local_port());
|
||||
}
|
||||
|
||||
NonnullRefPtr<UDPSocket> UDPSocket::create(int protocol)
|
||||
KResultOr<NonnullRefPtr<UDPSocket>> UDPSocket::create(int protocol)
|
||||
{
|
||||
return adopt_ref(*new UDPSocket(protocol));
|
||||
auto socket = adopt_ref_if_nonnull(new UDPSocket(protocol));
|
||||
if (socket)
|
||||
return socket.release_nonnull();
|
||||
return ENOMEM;
|
||||
}
|
||||
|
||||
KResultOr<size_t> UDPSocket::protocol_receive(ReadonlyBytes raw_ipv4_packet, UserOrKernelBuffer& buffer, size_t buffer_size, [[maybe_unused]] int flags)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue