]> git.ipfire.org Git - thirdparty/postgresql.git/commit
xml2: Fix stylesheet document leak in xslt_process()
authorMichael Paquier <michael@paquier.xyz>
Fri, 5 Jun 2026 05:29:27 +0000 (14:29 +0900)
committerMichael Paquier <michael@paquier.xyz>
Fri, 5 Jun 2026 05:29:27 +0000 (14:29 +0900)
commit9ec568b3eb6a8e8aad9041078e4c7bfedf293ca8
treee62007d0967f8825c5bba8d41d31f970331efc77
parent1a5b19e447aa6c2743371dc559f697cf63c7ba82
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
contrib/xml2/xslt_proc.c