From e8b85b13e2522d87a2514ea953fc0c80cfbcfee9 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 5 Dec 2021 15:30:40 +0100 Subject: [PATCH] LibWeb: Make CSSStyleSheet::m_owner_css_rule a WeakPtr It's not safe for this to be a raw pointer, as the imported style sheet can outlive the rule. --- Userland/Libraries/LibWeb/CSS/CSSRule.h | 4 +++- Userland/Libraries/LibWeb/CSS/CSSStyleSheet.h | 3 +-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Userland/Libraries/LibWeb/CSS/CSSRule.h b/Userland/Libraries/LibWeb/CSS/CSSRule.h index 6d04af17bb..156c055436 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSRule.h +++ b/Userland/Libraries/LibWeb/CSS/CSSRule.h @@ -8,6 +8,7 @@ #include #include +#include #include #include #include @@ -16,7 +17,8 @@ namespace Web::CSS { class CSSRule : public RefCounted - , public Bindings::Wrappable { + , public Bindings::Wrappable + , public Weakable { public: using WrapperType = Bindings::CSSRuleWrapper; diff --git a/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.h b/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.h index 9d08ef21ed..3ebe1877ce 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.h +++ b/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.h @@ -52,8 +52,7 @@ private: NonnullRefPtr m_rules; - // FIXME: Use WeakPtr. - CSSRule* m_owner_css_rule { nullptr }; + WeakPtr m_owner_css_rule; }; }