Parcourir la source

LibWeb: Fix uninitialized value in find_a_potential_indicated_element()

Andreas Kling il y a 1 an
Parent
commit
8730e56f62
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

@@ -1784,7 +1784,7 @@ Element* Document::find_a_potential_indicated_element(FlyString const& fragment)
 
 
     // 2. If there is an a element in the document tree whose root is document that has a name attribute
     // 2. If there is an a element in the document tree whose root is document that has a name attribute
     //    whose value is equal to fragment, then return the first such element in tree order.
     //    whose value is equal to fragment, then return the first such element in tree order.
-    Element* element_with_name;
+    Element* element_with_name = nullptr;
     root().for_each_in_subtree_of_type<Element>([&](Element const& element) {
     root().for_each_in_subtree_of_type<Element>([&](Element const& element) {
         if (element.attribute(HTML::AttributeNames::name) == fragment) {
         if (element.attribute(HTML::AttributeNames::name) == fragment) {
             element_with_name = const_cast<Element*>(&element);
             element_with_name = const_cast<Element*>(&element);