Fix low-probability memory leak in XMLSERIALIZE(... INDENT).

Tom Lane <tgl@sss.pgh.pa.us>

Commit: e03c95287764158941d317972a332565729b6af2
Author: Tom Lane <tgl@sss.pgh.pa.us>
Date: 2025-07-08T16:50:33Z
Fix low-probability memory leak in XMLSERIALIZE(... INDENT).

xmltotext_with_options() did not consider the possibility that
pg_xml_init() could fail --- most likely due to OOM.  If that
happened, the already-parsed xmlDoc structure would be leaked.
Oversight in commit 483bdb2af.

Bug: #18981
Author: Dmitry Kovalenko <d.kovalenko@postgrespro.ru>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/18981-9bc3c80f107ae925@postgresql.org
Backpatch-through: 16

Files

PathChange+/−
src/backend/utils/adt/xml.c modified +13 −8

Discussion