pgsql: xml2: Fix stylesheet document leak in xslt_process()

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: xml2: Fix stylesheet document leak in xslt_process()
Date: 2026-06-05 05:30:24
Message-ID: E1wVN8S-0018gt-0e@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: 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(dot)cherny(at)tantorlabs(dot)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(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Alexander Korotkov 2026-06-05 05:47:51 Re: pgsql: pg_dump: scope indAttNames per index in getIndexes()
Previous Message Fujii Masao 2026-06-05 00:52:53 pgsql: Fix pg_subscription column privileges for subwalrcvtimeout