1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-14 06:24:58 +00:00

LibWeb: Visit internal fields of Crypto in visit_edges

Not visiting the field holding SubtleCrypto in Crypto caused subtle
crashes all over the Value functions, due to accessing SubtleCrypto
after it was garbage collected (and potentially replaced by a new cell).
This meant that the crashes were only appearing in Value::to_boolean,
Value::typeof, etc. Which then held pointer to things that looked like
Shapes, Environments and other non-Object Cells.

To find the actual cause, all pointer used to construct Values were
checked and if a pointer was none of the allowed types, the backtrace
is logged.

Co-authored-by: Luke Wilde <lukew@serenityos.org>
This commit is contained in:
davidot 2022-09-13 01:23:28 +02:00 committed by Tim Flynn
parent 0e901f8c68
commit 1d846e5591
2 changed files with 9 additions and 0 deletions

View file

@ -114,4 +114,10 @@ String Crypto::random_uuid() const
return builder.to_string();
}
void Crypto::visit_edges(Cell::Visitor& visitor)
{
Base::visit_edges(visitor);
visitor.visit(m_subtle.ptr());
}
}

View file

@ -25,6 +25,9 @@ public:
DOM::ExceptionOr<JS::Value> get_random_values(JS::Value array) const;
String random_uuid() const;
protected:
virtual void visit_edges(Cell::Visitor&) override;
private:
explicit Crypto(HTML::Window&);
virtual void initialize(JS::Realm&) override;