Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 7a9af69f9b93c41f55a6861f2896b75c9648d621
      
https://github.com/WebKit/WebKit/commit/7a9af69f9b93c41f55a6861f2896b75c9648d621
  Author: David Kilzer <[email protected]>
  Date:   2026-01-26 (Mon, 26 Jan 2026)

  Changed paths:
    M Source/WebCore/xml/XPathNodeSet.cpp

  Log Message:
  -----------
  Fix -Wlifetime-safety-permissive warning in XPathNodeSet::findRootNode()
<https://bugs.webkit.org/show_bug.cgi?id=306226>
<rdar://problem/168880148>

Reviewed by Geoffrey Garen.

Clang's -Wlifetime-safety-permissive warning detected a potential issue
in the findRootNode() function.

The fix introduces `RefPtr<Node> current` to maintain proper lifetime
management throughout the function.  This is necessary because
`attr->ownerElement()` returns a raw pointer from a `WeakPtr<Element>`,
so when the `RefPtr attr` goes out of scope after the if statement,
nothing would keep the ownerElement alive if we stored it in a raw
pointer.

Similarly, the while loop's `RefPtr parent` was destroyed at the end of
each loop iteration while `node` held a raw pointer to it.  The while
loop is also changed to a for loop to avoid recreating the `RefPtr
parent` variable on each loop iteration.

findRootNode() is also changed to inline and to return `RefPtr<Node>`
since its single caller stores the result in a `RefPtr`.

No new tests since no change in behavior.

* Source/WebCore/xml/XPathNodeSet.cpp:
(WebCore::XPath::findRootNode):

Canonical link: https://commits.webkit.org/306240@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to