From d4a7e4e179f946e12708f758d30a07f931fd5a84 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Sat, 10 May 2025 20:22:39 -0400 Subject: [PATCH] Fix incorrect "return NULL" in BumpAllocLarge(). This must be "return MemoryContextAllocationFailure(context, size, flags)" instead. The effect of this oversight is that if we got a malloc failure right here, the code would act as though MCXT_ALLOC_NO_OOM had been specified, whether it was or not. That would likely lead to a null-pointer-dereference crash at the unsuspecting call site. Noted while messing with a patch to improve our Valgrind leak detection support. Back-patch to v17 where this code came in. --- src/backend/utils/mmgr/bump.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend/utils/mmgr/bump.c b/src/backend/utils/mmgr/bump.c index 434230fd95b..f7a37d1b3e8 100644 --- a/src/backend/utils/mmgr/bump.c +++ b/src/backend/utils/mmgr/bump.c @@ -316,7 +316,7 @@ BumpAllocLarge(MemoryContext context, Size size, int flags) block = (BumpBlock *) malloc(blksize); if (block == NULL) - return NULL; + return MemoryContextAllocationFailure(context, size, flags); context->mem_allocated += blksize; -- 2.30.2