summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/Crypto
diff options
context:
space:
mode:
authordavidot <davidot@serenityos.org>2022-09-13 01:23:28 +0200
committerTim Flynn <trflynn89@pm.me>2022-09-12 20:14:58 -0400
commit1d846e559150e1ec90486760a8e09fced24b1d67 (patch)
tree7cbd8b60f56fb3064825f46b02a5c43098841516 /Userland/Libraries/LibWeb/Crypto
parent0e901f8c68a7da573487c16506acb3a49371ddf1 (diff)
downloadserenity-1d846e559150e1ec90486760a8e09fced24b1d67.zip
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>
Diffstat (limited to 'Userland/Libraries/LibWeb/Crypto')
-rw-r--r--Userland/Libraries/LibWeb/Crypto/Crypto.cpp6
-rw-r--r--Userland/Libraries/LibWeb/Crypto/Crypto.h3
2 files changed, 9 insertions, 0 deletions
diff --git a/Userland/Libraries/LibWeb/Crypto/Crypto.cpp b/Userland/Libraries/LibWeb/Crypto/Crypto.cpp
index f9f1a3b2a2..f4626ac331 100644
--- a/Userland/Libraries/LibWeb/Crypto/Crypto.cpp
+++ b/Userland/Libraries/LibWeb/Crypto/Crypto.cpp
@@ -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());
+}
+
}
diff --git a/Userland/Libraries/LibWeb/Crypto/Crypto.h b/Userland/Libraries/LibWeb/Crypto/Crypto.h
index 8d0a782a2a..73e88d8375 100644
--- a/Userland/Libraries/LibWeb/Crypto/Crypto.h
+++ b/Userland/Libraries/LibWeb/Crypto/Crypto.h
@@ -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;