1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 13:37:44 +00:00

LibJS: Don't crash when calling byte_length for a detached ArrayBuffer

This commit is contained in:
PrestonLTaylor 2023-06-30 19:44:22 +01:00 committed by Jelle Raaijmakers
parent a036346e24
commit 286bf307d2
2 changed files with 9 additions and 7 deletions

View file

@ -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(); }