Skip to content

ext/xsl: free libxslt buffer when transformToXml output is empty#50

Closed
iliaal wants to merge 1 commit intoPHP-8.4from
fix/xsl-transformtoxml-leak-8.4
Closed

ext/xsl: free libxslt buffer when transformToXml output is empty#50
iliaal wants to merge 1 commit intoPHP-8.4from
fix/xsl-transformtoxml-leak-8.4

Conversation

@iliaal
Copy link
Copy Markdown
Owner

@iliaal iliaal commented Apr 27, 2026

xsltSaveResultToString can leave doc_txt_ptr non-NULL with doc_txt_len == 0. The previous gate if (doc_txt_ptr && doc_txt_len) skipped xmlFree in that case. Current libxslt (1.1.34) sets both fields to NULL/0 on empty output, so this is latent today, but a future libxslt change to that convention turns it into a per-transform leak. Free the buffer whenever it's allocated, regardless of length.

If xsltSaveResultToString sets doc_txt_ptr to a non-NULL allocation
but doc_txt_len to zero, the previous gate skipped xmlFree and leaked
the buffer. Current libxslt (1.1.34) sets both to NULL/0 in that case,
so this is latent today; the fix removes the dependency on that
convention.
@iliaal iliaal closed this Apr 27, 2026
@iliaal
Copy link
Copy Markdown
Owner Author

iliaal commented Apr 27, 2026

Superseded by php#21886.

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