agora inbox for pgsql-committers@postgresql.org
help / color / mirror / Atom feedFrom: David Rowley <drowley@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix missing MCXT_ALLOC_NO_OOM handling in MemoryContextAllocAlig
Date: Tue, 04 Aug 2026 04:10:31 +0000
Message-ID: <E1wr6U3-000000006ja-40Ck@gemulon.postgresql.org> (raw)
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
Branch
------
REL_17_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/cce758797f75c19080801ddad213f46d7900ec2b
Modified Files
--------------
src/backend/utils/mmgr/mcxt.c | 7 +++++++
1 file changed, 7 insertions(+)
view thread (5+ messages) latest in thread
Message-ID: <E1wr6U3-000000006ja-40Ck@gemulon.postgresql.org>
Permalink: ../E1wr6U3-000000006ja-40Ck@gemulon.postgresql.org/
Also on: postgresql.org/message-id/E1wr6U3-000000006ja-40Ck@gemulon.postgresql.org
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-committers@postgresql.org
Cc: drowley@postgresql.org, pgsql-committers@lists.postgresql.org
Subject: Re: pgsql: Fix missing MCXT_ALLOC_NO_OOM handling in MemoryContextAllocAlig
In-Reply-To: <E1wr6U3-000000006ja-40Ck@gemulon.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox