[php-src] PR #22562: ext/dom: fix use-after-free with XPath callback returning foreign-doc…
| From: | devnexen | Date: | Thu, 02 Jul 2026 19:12:41 +0000 |
| Subject: | [php-src] PR #22562: ext/dom: fix use-after-free with XPath callback returning foreign-doc… | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-36786@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/22562
Author: devnexen
…ument node.
Fix GH-22554
A PHP XPath callback that returns a node belonging to a document created inside the callback (e.g.
$d->documentElement of a throwaway DOMDocument) parks that node in the DOMXPath node_list to keep
it alive. When a sibling callback consumes a node navigated into that foreign document, the proxy
object was created with the DOMXPath's own dom as parent, so it took a reference on the wrong
document and none on the foreign one. On teardown the foreign document could be freed while the
proxy still referenced it.
Route the proxy factory through dom_xpath_intern_for_doc() so the created object shares the ref_obj
of the node's actual document, mirroring the query-result path.