修复数组计算元素个数整数溢出问题

This commit is contained in:
hwhbj
2024-01-04 15:09:52 +08:00
parent 7ec816b036
commit abebe5f89d
5 changed files with 107 additions and 18 deletions

View File

@ -58,6 +58,13 @@
#include "fmgr.h"
/*
* Maximum number of elements in an array. We limit this to at most about a
* quarter billion elements, so that it's not necessary to check for overflow
* in quite so many places --- for instance when polloc'ing Datum arrays.
*/
#define MaxArraySize ((Size)(MaxAllocSize) / sizeof(Datum))
/*
* Arrays are varlena objects, so must meet the varlena convention that
* the first int32 of the object contains the total object size in bytes.