xml2: Fix stylesheet document leak in xslt_process()
Michael Paquier <michael@paquier.xyz>
xml2: Fix stylesheet document leak in xslt_process() xslt_process() parses the stylesheet text into an xmlDoc before passing it to xsltParseStylesheetDoc(). On success, the returned stylesheet owns that document and frees it through xsltFreeStylesheet(), calling xmlFreeDoc() at its end. On failure, libxslt leaves the caller responsible for the xmlDoc. In xml2, this would cause the memory allocated for the xmlDoc to pile up across calls of xslt_process() when failing to create a sheet. While on it, I have double-checked the code of xml2 with libxslt, and it seems that we are in the clear now, hopefully.. This leak exists for a long time. 732061150b0 has made the fix introduced in this commit easier to implement. Author: Andrey Chernyy <andrey.cherny@tantorlabs.com> Discussion: https://postgr.es/m/20260605024642.5a1b6518@andrnote
Files
| Path | Change | +/− |
|---|---|---|
| contrib/xml2/xslt_proc.c | modified | +9 −2 |
Discussion
- [PATCH] xml2: Fix stylesheet document leak in xslt_process() 2 messages · 2026-06-04 → 2026-06-05