mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 20:29:18 +00:00
Kernel: Make IPv4Socket::create API for SOCK_RAW OOM safe
This commit is contained in:
parent
46ce7adf7b
commit
858fff979a
Notes:
sideshowbarker
2024-07-18 18:14:33 +09:00
Author: https://github.com/bgianfo
Commit: 858fff979a
Pull-request: https://github.com/SerenityOS/serenity/pull/7077
1 changed files with 6 additions and 2 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue