diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2025-05-10 20:22:39 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2025-05-10 20:22:39 -0400 |
commit | a05cf22e0540e55fb34e26e6e98a8a76b76d1cbd (patch) | |
tree | 94d0cf99c2a483a4a4148ca9dfa0c36c6c10a456 /src/backend/utils/mmgr | |
parent | 3007fee7f2924e76748e81d7fd86cdf24a98a520 (diff) |
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.
Diffstat (limited to 'src/backend/utils/mmgr')
-rw-r--r-- | src/backend/utils/mmgr/bump.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/backend/utils/mmgr/bump.c b/src/backend/utils/mmgr/bump.c index c60c9c131e3..afd7fe04ab0 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; |