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 <[email protected]>
Discussion: https://postgr.es/m/20260605024642.5a1b6518@andrnote

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/9ec568b3eb6a8e8aad9041078e4c7bfedf293ca8

Modified Files
--------------
contrib/xml2/xslt_proc.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)

Reply via email to