pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Fix memory leak in XMLSERIALIZE(... INDENT).
3+ messages / 1 participants
[nested] [flat]

* pgsql: Fix memory leak in XMLSERIALIZE(... INDENT).
@ 2025-05-22 17:52  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 3+ messages in thread

From: Tom Lane @ 2025-05-22 17:52 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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@sss.pgh.pa.us>
Reviewed-by: Jim Jones <jim.jones@uni-muenster.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(-)



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* pgsql: Fix memory leak in XMLSERIALIZE(... INDENT).
@ 2025-05-22 17:52  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 3+ messages in thread

From: Tom Lane @ 2025-05-22 17:52 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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@sss.pgh.pa.us>
Reviewed-by: Jim Jones <jim.jones@uni-muenster.de>
Discussion: https://postgr.es/m/1358967.1747858817@sss.pgh.pa.us
Backpatch-through: 16

Branch
------
master

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

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



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* pgsql: Fix memory leak in XMLSERIALIZE(... INDENT).
@ 2025-05-22 17:52  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 3+ messages in thread

From: Tom Lane @ 2025-05-22 17:52 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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@sss.pgh.pa.us>
Reviewed-by: Jim Jones <jim.jones@uni-muenster.de>
Discussion: https://postgr.es/m/1358967.1747858817@sss.pgh.pa.us
Backpatch-through: 16

Branch
------
REL_17_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/20bae0690322a00402b84119ddf2f959d24a211a

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



^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2025-05-22 17:52 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2025-05-22 17:52 pgsql: Fix memory leak in XMLSERIALIZE(... INDENT). Tom Lane <tgl@sss.pgh.pa.us>
2025-05-22 17:52 pgsql: Fix memory leak in XMLSERIALIZE(... INDENT). Tom Lane <tgl@sss.pgh.pa.us>
2025-05-22 17:52 pgsql: Fix memory leak in XMLSERIALIZE(... INDENT). Tom Lane <tgl@sss.pgh.pa.us>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox