mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 17:07:34 +00:00
LibJS: Propagate OOM in GetModifySetValueInBuffer AO
This commit is contained in:
parent
81c8e642b9
commit
49c8d22f50
2 changed files with 6 additions and 7 deletions
|
@ -76,7 +76,7 @@ public:
|
|||
template<typename type>
|
||||
void set_value(size_t byte_index, Value value, bool is_typed_array, Order, bool is_little_endian = true);
|
||||
template<typename T>
|
||||
Value get_modify_set_value(size_t byte_index, Value value, ReadWriteModifyFunction operation, bool is_little_endian = true);
|
||||
ThrowCompletionOr<Value> get_modify_set_value(size_t byte_index, Value value, ReadWriteModifyFunction operation, bool is_little_endian = true);
|
||||
|
||||
private:
|
||||
ArrayBuffer(ByteBuffer buffer, Object& prototype);
|
||||
|
@ -274,16 +274,15 @@ void ArrayBuffer::set_value(size_t byte_index, Value value, [[maybe_unused]] boo
|
|||
|
||||
// 25.1.2.13 GetModifySetValueInBuffer ( arrayBuffer, byteIndex, type, value, op [ , isLittleEndian ] ), https://tc39.es/ecma262/#sec-getmodifysetvalueinbuffer
|
||||
template<typename T>
|
||||
Value ArrayBuffer::get_modify_set_value(size_t byte_index, Value value, ReadWriteModifyFunction operation, bool is_little_endian)
|
||||
ThrowCompletionOr<Value> ArrayBuffer::get_modify_set_value(size_t byte_index, Value value, ReadWriteModifyFunction operation, bool is_little_endian)
|
||||
{
|
||||
auto& vm = this->vm();
|
||||
|
||||
auto raw_bytes = numeric_to_raw_bytes<T>(vm, value, is_little_endian).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
auto raw_bytes = MUST_OR_THROW_OOM(numeric_to_raw_bytes<T>(vm, value, is_little_endian));
|
||||
|
||||
// FIXME: Check for shared buffer
|
||||
|
||||
// FIXME: Propagate errors.
|
||||
auto raw_bytes_read = MUST(buffer_impl().slice(byte_index, sizeof(T)));
|
||||
auto raw_bytes_read = TRY_OR_THROW_OOM(vm, buffer_impl().slice(byte_index, sizeof(T)));
|
||||
auto raw_bytes_modified = operation(raw_bytes_read, raw_bytes);
|
||||
raw_bytes_modified.span().copy_to(buffer_impl().span().slice(byte_index));
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue