Add assertion for failed alloc to palloc0() and palloc_extended()

From: Andreas Karlsson <andreas(at)proxel(dot)se>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Add assertion for failed alloc to palloc0() and palloc_extended()
Date: 2025-03-01 00:05:43
Message-ID: 507e8eba-2035-4a12-a777-98199a66beb8@proxel.se
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

I noticed that we have Assert(ret != NULL) in palloc() but not in
palloc0() so for consistency I decided to add it. I also added an
assertion that the MCXT_ALLOC_NO_OOM flag is set if alloc() returns
NULL to palloc_extended().

I feel that this might be useful since while palloc() is much more
common the OOM which causes alloc() to incorrectly return NULL could in
theory happen in any of the three functions.

Andreas

Attachment Content-Type Size
0001-Add-assertion-for-failed-alloc-to-palloc0-and-palloc.patch text/x-patch 1.2 KB

Browse pgsql-hackers by date

  From Date Subject
Next Message Thomas Munro 2025-03-01 00:36:29 Re: [PoC] Federated Authn/z with OAUTHBEARER
Previous Message Thomas Munro 2025-02-28 23:38:37 Re: [PoC] Federated Authn/z with OAUTHBEARER