]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Fix missing MCXT_ALLOC_NO_OOM handling in MemoryContextAllocAligned REL_19_STABLE github/REL_19_STABLE
authorDavid Rowley <drowley@postgresql.org>
Tue, 4 Aug 2026 04:09:29 +0000 (16:09 +1200)
committerDavid Rowley <drowley@postgresql.org>
Tue, 4 Aug 2026 04:09:29 +0000 (16:09 +1200)
commit5cb0f004f179435dcb53b94e9b5827d540886b42
treef6d09c03a9f00a57c6a0af9140d7d2c2fc2560bb
parent98bcb0ab8aa3c783adc27e677ab861a4a8baa411
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.evan.chao@gmail.com>
Discussion: https://postgr.es/m/07DAC4C3-120D-4F3C-8FEE-BA236F7E9C1D@gmail.com
Backpatch-through: 16
src/backend/utils/mmgr/mcxt.c