Parcourir la source

LibWeb: Add missing null check while dispatching mouseenter events

Andreas Kling il y a 2 ans
Parent
commit
b4f9db84ca
1 fichiers modifiés avec 1 ajouts et 1 suppressions
  1. 1 1
      Userland/Libraries/LibWeb/DOM/Document.cpp

+ 1 - 1
Userland/Libraries/LibWeb/DOM/Document.cpp

@@ -954,7 +954,7 @@ void Document::set_hovered_node(Node* node)
     // https://w3c.github.io/uievents/#mouseenter
     if (m_hovered_node && (!old_hovered_node || !m_hovered_node->is_ancestor_of(*old_hovered_node))) {
         // FIXME: Check if we need to dispatch these events in a specific order.
-        for (auto target = m_hovered_node; target.ptr() != common_ancestor; target = target->parent()) {
+        for (auto target = m_hovered_node; target && target.ptr() != common_ancestor; target = target->parent()) {
             // FIXME: Populate the event with mouse coordinates, etc.
             target->dispatch_event(*UIEvents::MouseEvent::create(realm(), UIEvents::EventNames::mouseenter));
         }