1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 15:27:35 +00:00

LibJS: Handle possible allocation failure in ArrayBuffer(size_t)

...by replacing it with a ctor that takes the buffer instead, and
handling the allocation failure in ArrayBuffer::create(size_t) by
throwing a RangeError as specified by the spec.
This commit is contained in:
Ali Mohammad Pur 2021-09-05 14:43:15 +04:30 committed by Andreas Kling
parent d20fc922c5
commit 7589cc2494
5 changed files with 22 additions and 6 deletions

View file

@ -60,7 +60,11 @@ Value ArrayBufferConstructor::construct(FunctionObject&)
}
return {};
}
return ArrayBuffer::create(global_object(), byte_length);
auto array_buffer = ArrayBuffer::create(global_object(), byte_length);
if (!array_buffer)
return {};
return array_buffer;
}
// 25.1.4.1 ArrayBuffer.isView ( arg ), https://tc39.es/ecma262/#sec-arraybuffer.isview