Skip to content

Fix DOMXPath crash wrapping a foreign node after a nodeset callback - #230

Closed
iliaal wants to merge 1 commit into
PHP-8.5from
fix/xpath-foreign-doc
Closed

Fix DOMXPath crash wrapping a foreign node after a nodeset callback#230
iliaal wants to merge 1 commit into
PHP-8.5from
fix/xpath-foreign-doc

Conversation

@iliaal

@iliaal iliaal commented Aug 13, 2026

Copy link
Copy Markdown
Owner

xpath_callbacks.node_list stores both DOM objects and arrays (nodeset-mode php:function args). dom_xpath_intern_for_doc did Z_DOMOBJ_P on every entry. Same-document results take the early return; a later callback that returns a node from another document walks leftover arrays first. This skips non-objects and recurses into arrays. PHP-8.5 is the lowest branch with intern_for_doc.

dom_xpath_intern_for_doc walked xpath_callbacks.node_list with
Z_DOMOBJ_P on every entry. That list also stores arrays (nodeset-mode
callback arguments). Same-document results take the early return; a
later php:function that returns a node from another document walks
the leftover array first. Skip non-objects and recurse into arrays
so the matching intern is found instead of type-confusing the array.
@iliaal

iliaal commented Aug 13, 2026

Copy link
Copy Markdown
Owner Author

Promoted to php#23253.

@iliaal iliaal closed this Aug 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant