diff --git a/Userland/Libraries/LibJS/Runtime/ArrayBuffer.h b/Userland/Libraries/LibJS/Runtime/ArrayBuffer.h index b6050da679..575eb77a98 100644 --- a/Userland/Libraries/LibJS/Runtime/ArrayBuffer.h +++ b/Userland/Libraries/LibJS/Runtime/ArrayBuffer.h @@ -164,11 +164,11 @@ Value ArrayBuffer::get_value(size_t byte_index, [[maybe_unused]] bool is_typed_a // 25.1.2.11 NumericToRawBytes ( type, value, isLittleEndian ), https://tc39.es/ecma262/#sec-numerictorawbytes template -static ByteBuffer numeric_to_raw_bytes(VM& vm, Value value, bool is_little_endian) +static ThrowCompletionOr numeric_to_raw_bytes(VM& vm, Value value, bool is_little_endian) { VERIFY(value.is_number() || value.is_bigint()); using UnderlyingBufferDataType = Conditional, u8, T>; - ByteBuffer raw_bytes = ByteBuffer::create_uninitialized(sizeof(UnderlyingBufferDataType)).release_value_but_fixme_should_propagate_errors(); // FIXME: Handle possible OOM situation. + ByteBuffer raw_bytes = TRY_OR_THROW_OOM(vm, ByteBuffer::create_uninitialized(sizeof(UnderlyingBufferDataType))); auto flip_if_needed = [&]() { if (is_little_endian) return; @@ -254,7 +254,7 @@ void ArrayBuffer::set_value(size_t byte_index, Value value, [[maybe_unused]] boo // NOTE: Done by default parameter at declaration of this function. // 7. Let rawBytes be NumericToRawBytes(type, value, isLittleEndian). - auto raw_bytes = numeric_to_raw_bytes(vm, value, is_little_endian); + auto raw_bytes = numeric_to_raw_bytes(vm, value, is_little_endian).release_allocated_value_but_fixme_should_propagate_errors(); // FIXME 8. If IsSharedArrayBuffer(arrayBuffer) is true, then if (false) { @@ -278,7 +278,7 @@ Value ArrayBuffer::get_modify_set_value(size_t byte_index, Value value, ReadWrit { auto& vm = this->vm(); - auto raw_bytes = numeric_to_raw_bytes(vm, value, is_little_endian); + auto raw_bytes = numeric_to_raw_bytes(vm, value, is_little_endian).release_allocated_value_but_fixme_should_propagate_errors(); // FIXME: Check for shared buffer diff --git a/Userland/Libraries/LibJS/Runtime/AtomicsObject.cpp b/Userland/Libraries/LibJS/Runtime/AtomicsObject.cpp index 02af92a8ad..a631ebbaf9 100644 --- a/Userland/Libraries/LibJS/Runtime/AtomicsObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/AtomicsObject.cpp @@ -230,10 +230,10 @@ static ThrowCompletionOr atomic_compare_exchange_impl(VM& vm, TypedArrayB constexpr bool is_little_endian = __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__; // 11. Let expectedBytes be NumericToRawBytes(elementType, expected, isLittleEndian). - auto expected_bytes = numeric_to_raw_bytes(vm, expected, is_little_endian); + auto expected_bytes = MUST_OR_THROW_OOM(numeric_to_raw_bytes(vm, expected, is_little_endian)); // 12. Let replacementBytes be NumericToRawBytes(elementType, replacement, isLittleEndian). - auto replacement_bytes = numeric_to_raw_bytes(vm, replacement, is_little_endian); + auto replacement_bytes = MUST_OR_THROW_OOM(numeric_to_raw_bytes(vm, replacement, is_little_endian)); // FIXME: Implement SharedArrayBuffer case. // 13. If IsSharedArrayBuffer(buffer) is true, then