Skip to content

Commit a05cf22

Browse files
committed
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.
1 parent 3007fee commit a05cf22

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)