Skip to content

Commit 7ccfbd1

Browse files
tglsfdchopebo
authored andcommitted
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. (cherry picked from commit a05cf22e0540e55fb34e26e6e98a8a76b76d1cbd)
1 parent ae5472f commit 7ccfbd1

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/backend/utils/mmgr/bump.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ BumpAllocLarge(MemoryContext context, Size size, int flags)
316316

317317
block = (BumpBlock *) malloc(blksize);
318318
if (block == NULL)
319-
return NULL;
319+
return MemoryContextAllocationFailure(context, size, flags);
320320

321321
context->mem_allocated += blksize;
322322

0 commit comments

Comments
 (0)