Re: [PATCH] xml2: Fix stylesheet document leak in xslt_process() - Mailing list pgsql-hackers

From Michael Paquier
Subject Re: [PATCH] xml2: Fix stylesheet document leak in xslt_process()
Date
Msg-id aiJWUH85UH4nVex_@paquier.xyz
Whole thread
In response to [PATCH] xml2: Fix stylesheet document leak in xslt_process()  (Andrey Chernyy <andrey.cherny@tantorlabs.com>)
List pgsql-hackers
On Fri, Jun 05, 2026 at 02:46:42AM +0300, Andrey Chernyy wrote:
> xslt_process() parses the stylesheet argument with xmlReadMemory(), then
> passes the resulting xmlDoc to xsltParseStylesheetDoc().  On failure,
> libxslt leaves that document owned by the caller, as can be seen from
> its own xsltParseStylesheetFile() wrapper.  Postgres currently cannot
> release it in the error cleanup path because ssdoc is scoped inside the
> PG_TRY block.

In libxslt/xslt.c, the top comment of xsltParseStylesheetDoc() says:
"the doc is automatically freed when the stylesheet is closed."

Reading the code, I can confirm that xsltFreeStylesheet() does a bunch
of stuff, and that it has the idea to call xmlFreeDoc() once at the
end.

Will address this one as well.  Thanks.
--
Michael

Attachment

pgsql-hackers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: [PATCH] Use ssup_datum_*_cmp for int2, oid, and oid8 sort support
Next
From: Michael Paquier
Date:
Subject: Re: Heads Up: cirrus-ci is shutting down June 1st