From 4e0a9267374314a777d40bb11ff445958268ceec Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Tue, 24 Oct 2023 11:32:48 -0400 Subject: [PATCH] LibWeb: Protect ad-hoc `scroll` against a potentially null paintable box We perform such a check in other users of the paintable box in this file as the box may be null before layout completes. This prevents UB seen in some CI runs. --- Userland/Libraries/LibWeb/DOM/Element.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibWeb/DOM/Element.cpp b/Userland/Libraries/LibWeb/DOM/Element.cpp index 03e9bb05fb..0d34c19876 100644 --- a/Userland/Libraries/LibWeb/DOM/Element.cpp +++ b/Userland/Libraries/LibWeb/DOM/Element.cpp @@ -1924,7 +1924,8 @@ HashMap const& Element::custom_properti void Element::scroll(double x, double y) { // AD-HOC: - paintable_box()->scroll_by(x, y); + if (auto* paintable_box = this->paintable_box()) + paintable_box->scroll_by(x, y); } // https://drafts.csswg.org/cssom-view/#dom-element-scroll