| From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
|---|---|
| To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
| Subject: | pgsql: Fix double-free when XMLSERIALIZE(... INDENT) output exceeds 1GB |
| Date: | 2026-11-02 01:46:16 |
| Message-ID: | E1xNh7o-00000001jJq-0K9H@gemulon.postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-committers |
Fix double-free when XMLSERIALIZE(... INDENT) output exceeds 1GB.
In xmltotext_with_options(), xmlSaveClose() frees the save context
unconditionally, but ctxt was only reset to NULL on the error branch.
When the close succeeded and a later step threw an error -- typically,
cstring_to_text_with_len() rejecting a result larger than MaxAllocSize
-- control reached the PG_CATCH block with ctxt still pointing at the
freed context, so xmlSaveClose() was called a second time on freed
memory and crashed the backend.
Author: Jim Jones <jim(dot)jones(at)uni-muenster(dot)de>
Reviewed-by: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Discussion: https://postgr.es/m/bbadb6b2-d226-41a1-ace3-e0eb20648f58@uni-muenster.de
Backpatch-through: 16
Branch
------
REL_16_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/582db3ee09e9d2128c2510937bbc3c9f763d97bf
Modified Files
--------------
src/backend/utils/adt/xml.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Richard Guo | 2026-11-02 05:42:15 | pgsql: Fix reuse of stale hash tables by duplicated hashed SubPlans |
| Previous Message | Tom Lane | 2026-11-02 01:46:15 | pgsql: Fix double-free when XMLSERIALIZE(... INDENT) output exceeds 1GB |