mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 20:37:36 +00:00
LibJS: Don't crash when calling byte_length for a detached ArrayBuffer
This commit is contained in:
parent
a036346e24
commit
286bf307d2
2 changed files with 9 additions and 7 deletions
|
@ -32,7 +32,13 @@ public:
|
|||
|
||||
virtual ~ArrayBuffer() override = default;
|
||||
|
||||
size_t byte_length() const { return buffer_impl().size(); }
|
||||
size_t byte_length() const
|
||||
{
|
||||
if (is_detached())
|
||||
return 0;
|
||||
|
||||
return buffer_impl().size();
|
||||
}
|
||||
|
||||
// [[ArrayBufferData]]
|
||||
ByteBuffer& buffer() { return buffer_impl(); }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue