pgsql: xml2: Fix stylesheet document leak in xslt_process() - Mailing list pgsql-committers

From Michael Paquier
Subject pgsql: xml2: Fix stylesheet document leak in xslt_process()
Date
Msg-id E1wVN8S-0018gt-0e@gemulon.postgresql.org
Whole thread
List pgsql-committers
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

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(-)


pgsql-committers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: pgsql: pg_dump: scope indAttNames per index in getIndexes()
Next
From: Alexander Korotkov
Date:
Subject: Re: pgsql: pg_dump: scope indAttNames per index in getIndexes()