| From: | David Rowley <drowley(at)postgresql(dot)org> |
|---|---|
| To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
| Subject: | pgsql: Fix missing MCXT_ALLOC_NO_OOM handling in MemoryContextAllocAlig |
| Date: | 2026-08-04 04:09:46 |
| Message-ID: | E1wr6TK-000000006gj-2G8O@gemulon.postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-committers |
Fix missing MCXT_ALLOC_NO_OOM handling in MemoryContextAllocAligned
Fix missing NULL check in MemoryContextAllocAligned(). The underlying
call to MemoryContextAllocExtended() could return NULL when
flags contains MCXT_ALLOC_NO_OOM and the underlying malloc fails.
There are no current callers using MemoryContextAllocAligned() that pass
the MCXT_ALLOC_NO_OOM in core, so no live bug fix in core here. However,
an extension might use this pattern, so we'd better fix.
Fix this so we correctly pass the NULL to the caller rather than trying
to write to a NULL memory address.
This also fixes the same bug in AlignedAllocRealloc(), which is also
unused in core.
Backpatch to v16, where these functions first appeared.
Author: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
Discussion: https://postgr.es/m/07DAC4C3-120D-4F3C-8FEE-BA236F7E9C1D@gmail.com
Backpatch-through: 16
Branch
------
REL_19_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/5cb0f004f179435dcb53b94e9b5827d540886b42
Modified Files
--------------
src/backend/utils/mmgr/mcxt.c | 7 +++++++
1 file changed, 7 insertions(+)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | David Rowley | 2026-08-04 04:10:11 | pgsql: Fix missing MCXT_ALLOC_NO_OOM handling in MemoryContextAllocAlig |
| Previous Message | David Rowley | 2026-08-04 04:09:11 | pgsql: Fix missing MCXT_ALLOC_NO_OOM handling in MemoryContextAllocAlig |