Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d4a7e4e

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 4a4ee0c commit d4a7e4e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/backend/utils/mmgr/bump.c

+1-1
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)