summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibJS/Runtime
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/LibJS/Runtime
parent3a9f00c59bad7735970c72cb940d08161fda09b0 (diff)
downloadserenity-97e97bccab085823d1365cb54142fd8c41dbcd8c.zip
Everywhere: Make ByteBuffer::{create_*,copy}() OOM-safe
Diffstat (limited to 'Userland/Libraries/LibJS/Runtime')
-rw-r--r--Userland/Libraries/LibJS/Runtime/ArrayBuffer.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/ArrayBuffer.h2
2 files changed, 2 insertions, 2 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/ArrayBuffer.cpp b/Userland/Libraries/LibJS/Runtime/ArrayBuffer.cpp
index 0f5419c9f4..3a0b543fce 100644
--- a/Userland/Libraries/LibJS/Runtime/ArrayBuffer.cpp
+++ b/Userland/Libraries/LibJS/Runtime/ArrayBuffer.cpp
@@ -21,7 +21,7 @@ ArrayBuffer* ArrayBuffer::create(GlobalObject& global_object, ByteBuffer* buffer
ArrayBuffer::ArrayBuffer(size_t byte_size, Object& prototype)
: Object(prototype)
- , m_buffer(ByteBuffer::create_zeroed(byte_size))
+ , m_buffer(ByteBuffer::create_zeroed(byte_size).release_value()) // FIXME: Handle this possible OOM failure.
, m_detach_key(js_undefined())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/ArrayBuffer.h b/Userland/Libraries/LibJS/Runtime/ArrayBuffer.h
index 681f363190..5868ef29cb 100644
--- a/Userland/Libraries/LibJS/Runtime/ArrayBuffer.h
+++ b/Userland/Libraries/LibJS/Runtime/ArrayBuffer.h
@@ -125,7 +125,7 @@ template<typename T>
static ByteBuffer numeric_to_raw_bytes(GlobalObject& global_object, Value value, bool is_little_endian)
{
using UnderlyingBufferDataType = Conditional<IsSame<ClampedU8, T>, u8, T>;
- ByteBuffer raw_bytes = ByteBuffer::create_uninitialized(sizeof(UnderlyingBufferDataType));
+ ByteBuffer raw_bytes = ByteBuffer::create_uninitialized(sizeof(UnderlyingBufferDataType)).release_value(); // FIXME: Handle possible OOM situation.
auto flip_if_needed = [&]() {
if (is_little_endian)
return;