From 97e97bccab085823d1365cb54142fd8c41dbcd8c Mon Sep 17 00:00:00 2001 From: Ali Mohammad Pur Date: Mon, 6 Sep 2021 03:29:52 +0430 Subject: Everywhere: Make ByteBuffer::{create_*,copy}() OOM-safe --- Userland/Libraries/LibJS/Runtime/ArrayBuffer.cpp | 2 +- Userland/Libraries/LibJS/Runtime/ArrayBuffer.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'Userland/Libraries/LibJS/Runtime') 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 static ByteBuffer numeric_to_raw_bytes(GlobalObject& global_object, Value value, bool is_little_endian) { using UnderlyingBufferDataType = Conditional, 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; -- cgit v1.2.3