mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-03 08:08:43 +00:00
LibJS: Don't crash when calling byte_length for a detached ArrayBuffer
This commit is contained in:
parent
a036346e24
commit
286bf307d2
Notes:
sideshowbarker
2024-07-17 01:12:07 +09:00
Author: https://github.com/PrestonLTaylor
Commit: 286bf307d2
Pull-request: https://github.com/SerenityOS/serenity/pull/19718
Reviewed-by: https://github.com/linusg ✅
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