summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibProtocol
diff options
context:
space:
mode:
authorAli Mohammad Pur <ali.mpfard@gmail.com>2021-09-06 03:29:52 +0430
committerAndreas Kling <kling@serenityos.org>2021-09-06 01:53:26 +0200
commit97e97bccab085823d1365cb54142fd8c41dbcd8c (patch)
tree9008687dbcdfb6f36f6dc6372aa382b15b9d36c8 /Userland/Libraries/LibProtocol
parent3a9f00c59bad7735970c72cb940d08161fda09b0 (diff)
downloadserenity-97e97bccab085823d1365cb54142fd8c41dbcd8c.zip
Everywhere: Make ByteBuffer::{create_*,copy}() OOM-safe
Diffstat (limited to 'Userland/Libraries/LibProtocol')
-rw-r--r--Userland/Libraries/LibProtocol/RequestClient.cpp6
-rw-r--r--Userland/Libraries/LibProtocol/WebSocket.cpp4
2 files changed, 8 insertions, 2 deletions
diff --git a/Userland/Libraries/LibProtocol/RequestClient.cpp b/Userland/Libraries/LibProtocol/RequestClient.cpp
index 613c262223..00a3f57c58 100644
--- a/Userland/Libraries/LibProtocol/RequestClient.cpp
+++ b/Userland/Libraries/LibProtocol/RequestClient.cpp
@@ -22,7 +22,11 @@ RefPtr<Request> RequestClient::start_request(String const& method, URL const& ur
for (auto& it : request_headers)
header_dictionary.add(it.key, it.value);
- auto response = IPCProxy::start_request(method, url, header_dictionary, ByteBuffer::copy(request_body));
+ auto body_result = ByteBuffer::copy(request_body);
+ if (!body_result.has_value())
+ return nullptr;
+
+ auto response = IPCProxy::start_request(method, url, header_dictionary, body_result.release_value());
auto request_id = response.request_id();
if (request_id < 0 || !response.response_fd().has_value())
return nullptr;
diff --git a/Userland/Libraries/LibProtocol/WebSocket.cpp b/Userland/Libraries/LibProtocol/WebSocket.cpp
index 5d497e1a18..c97f4027d3 100644
--- a/Userland/Libraries/LibProtocol/WebSocket.cpp
+++ b/Userland/Libraries/LibProtocol/WebSocket.cpp
@@ -27,7 +27,9 @@ void WebSocket::send(ByteBuffer binary_or_text_message, bool is_text)
void WebSocket::send(StringView text_message)
{
- send(ByteBuffer::copy(text_message.bytes()), true);
+ auto data_result = ByteBuffer::copy(text_message.bytes());
+ VERIFY(data_result.has_value());
+ send(data_result.release_value(), true);
}
void WebSocket::close(u16 code, String reason)