]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Make GetSnapshotData() more resilient on out-of-memory errors
authorMichael Paquier <michael@paquier.xyz>
Thu, 18 Jun 2026 05:05:27 +0000 (14:05 +0900)
committerMichael Paquier <michael@paquier.xyz>
Thu, 18 Jun 2026 05:05:27 +0000 (14:05 +0900)
commit29fb598b9cad898ef851b9a7704f980218057562
tree89eca8f8acf7bea36bbbe528df1a697e692b8e2e
parentbdae2c20e88d80c63bd8de2c57aebd9cea590bc7
Make GetSnapshotData() more resilient on out-of-memory errors

If the allocation of Snapshot->subxip fails, a follow-up call of
GetSnapshotData() would see a partially-initialized snapshot, causing a
NULL dereference on reentry when using "subxip" because only "xip" would
be allocated.  In the event of an out-of-memory error when allocating
"subxip", "xip" is now reset before throwing an ERROR, so as Snapshots
can be allocated and handled gracefully on retry.

This problem is unlikely going to show up in practice, so no backpatch.

Reported-by: Alexander Lakhin <exclusion@gmail.com>
Author: Matthias van de Meent <boekewurm+postgres@gmail.com>
Discussion: https://postgr.es/m/e77acaac-a1b3-40b3-99ee-5769b4e453e4@gmail.com
src/backend/storage/ipc/procarray.c