1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 15:48:12 +00:00

Kernel: Make IPv4Socket::create API for SOCK_RAW OOM safe

This commit is contained in:
Brian Gianforcaro 2021-05-13 01:24:44 -07:00 committed by Andreas Kling
parent 46ce7adf7b
commit 858fff979a

View file

@ -44,8 +44,12 @@ KResultOr<NonnullRefPtr<Socket>> IPv4Socket::create(int type, int protocol)
}
if (type == SOCK_DGRAM)
return UDPSocket::create(protocol);
if (type == SOCK_RAW)
return adopt_ref(*new IPv4Socket(type, protocol));
if (type == SOCK_RAW) {
auto raw_socket = adopt_ref_if_nonnull(new IPv4Socket(type, protocol));
if (raw_socket)
return raw_socket.release_nonnull();
return ENOMEM;
}
return EINVAL;
}