Skip to content

ext/xsl: Fix use-after-free on a nested transform of the same processor - #462

Closed
iliaal wants to merge 1 commit into
masterfrom
fix/xsl-nested-transform
Closed

iliaal wants to merge 1 commit into
masterfrom
fix/xsl-nested-transform

Conversation

@iliaal

@iliaal iliaal commented Nov 9, 2026

Copy link
Copy Markdown
Owner

Starting a second transformation on an XSLTProcessor that is already transforming, from a php:function() callback or from main code while a Fiber is suspended inside one, overwrote the processor's document reference and callback node list under the running transformation, which then read freed memory. Throw an Error for such a call, as importStylesheet() already does. A callback that bails out also no longer leaves the processor marked as transforming.

Found while reworking #461, which stacks on this. Red on master under ASAN (heap-use-after-free in dom_objects_free_storage), green patched; ext/xsl and ext/dom suites clean.

php_xsl_apply_stylesheet() keeps the transformation's document reference in
intern->doc and the callback node wrappers in the processor's node list, so a
second transformation on the same processor, started from a php:function()
callback or from main code while a Fiber is suspended inside one, freed that
state under the running transformation. Throw an Error for such a call, as
importStylesheet() already does, and restore transform_depth when a callback
bails out so that the processor remains usable in shutdown functions.
@iliaal

iliaal commented Nov 9, 2026

Copy link
Copy Markdown
Owner Author

Submitted upstream as php#25355.

@iliaal iliaal closed this Nov 9, 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