1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 02:27:43 +00:00

js: Handle detached ArrayBuffer in print_typed_array()

Co-authored-by: Idan Horowitz <idan.horowitz@gmail.com>
This commit is contained in:
Linus Groh 2021-07-04 17:36:10 +01:00
parent bb1a98d809
commit c9d8aa6139

View file

@ -378,6 +378,7 @@ static void print_number(T number) requires IsArithmetic<T>
static void print_typed_array(const JS::Object& object, HashTable<JS::Object*>& seen_objects) static void print_typed_array(const JS::Object& object, HashTable<JS::Object*>& seen_objects)
{ {
auto& typed_array_base = static_cast<const JS::TypedArrayBase&>(object); auto& typed_array_base = static_cast<const JS::TypedArrayBase&>(object);
auto& array_buffer = *typed_array_base.viewed_array_buffer();
auto length = typed_array_base.array_length(); auto length = typed_array_base.array_length();
print_type(object.class_name()); print_type(object.class_name());
out("\n length: "); out("\n length: ");
@ -386,8 +387,10 @@ static void print_typed_array(const JS::Object& object, HashTable<JS::Object*>&
print_value(JS::Value(typed_array_base.byte_length()), seen_objects); print_value(JS::Value(typed_array_base.byte_length()), seen_objects);
out("\n buffer: "); out("\n buffer: ");
print_type("ArrayBuffer"); print_type("ArrayBuffer");
out(" @ {:p}", typed_array_base.viewed_array_buffer()); if (array_buffer.is_detached())
if (!length) out(" (detached)");
out(" @ {:p}", &array_buffer);
if (!length || array_buffer.is_detached())
return; return;
outln(); outln();
// FIXME: This kinda sucks. // FIXME: This kinda sucks.