pgsql: Fix memory leak in XMLSERIALIZE(... INDENT).

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix memory leak in XMLSERIALIZE(... INDENT).
Date: 2025-05-22 17:52:54
Message-ID: E1uIA6A-000Hob-0e@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix memory leak in XMLSERIALIZE(... INDENT).

xmltotext_with_options sometimes tries to replace the existing
root node of a libxml2 document. In that case xmlDocSetRootElement
will unlink and return the old root node; if we fail to free it,
it's leaked for the remainder of the session. The amount of memory
at stake is not large, a couple hundred bytes per occurrence, but
that could still become annoying in heavy usage.

Our only other xmlDocSetRootElement call is not at risk because
it's working on a just-created document, but let's modify that
code too to make it clear that it's dependent on that.

Author: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Reviewed-by: Jim Jones <jim(dot)jones(at)uni-muenster(dot)de>
Discussion: https://postgr.es/m/1358967.1747858817@sss.pgh.pa.us
Backpatch-through: 16

Branch
------
REL_16_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/ee58de10084b42a24aaa3ab4af7713bb2fe02ab4

Modified Files
--------------
src/backend/utils/adt/xml.c | 21 +++++++++++++++++----
1 file changed, 17 insertions(+), 4 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2025-05-22 17:58:33 Re: GSS Auth issue when user member of lots of AD groups
Previous Message Jacob Champion 2025-05-22 17:11:53 Re: GSS Auth issue when user member of lots of AD groups