diff --git a/src/backend/utils/mmgr/aset.c b/src/backend/utils/mmgr/aset.c index 3c5d651..ae733d8 100644 --- a/src/backend/utils/mmgr/aset.c +++ b/src/backend/utils/mmgr/aset.c @@ -860,17 +860,16 @@ AllocSetAlloc(MemoryContext context, Size size) * We could be asking for pretty big blocks here, so cope if malloc * fails. But give up if there's less than a meg or so available... */ - while (block == NULL && blksize > 1024 * 1024) + while (block == NULL) { blksize >>= 1; - if (blksize < required_size) - break; + + /* has the block size gotten too small? */ + if (blksize < required_size || blksize <= 1024 * 1024) + return NULL; block = (AllocBlock) malloc(blksize); } - if (block == NULL) - return NULL; - context->mem_allocated += blksize; block->aset = set;