1
0
mirror of https://github.com/postgres/postgres.git synced 2026-10-23 13:29:09 +03:00

Use safer allocation routines in more places of the tree

This is part of a more global effort to modernize the code tree with
safer allocation functions, which offer more protection in terms of:
- stronger type safety guarantees
- size overflow checks, particulary for arrays.

This set of updates includes allocation changes based on
palloc_object(), palloc_array() and repalloc_array().  This work is
similar to 1b105f9472, expanding more the new APIs in the tree in an
incremental fashion.

Author: Tristan Partin <tristan@partin.io>
Discussion: https://postgr.es/m/DKJB5887LGX9.359DV1UMZ1URK@partin.io
This commit is contained in:
Michael Paquier
2026-08-17 16:15:45 +09:00
parent 4fb6e9eb75
commit 51c43a5dbd
234 changed files with 728 additions and 892 deletions

View File

@@ -485,7 +485,7 @@ ExecInitGenerated(ResultRelInfo *resultRelInfo,
*/
oldContext = MemoryContextSwitchTo(estate->es_query_cxt);
ri_GeneratedExprs = (ExprState **) palloc0(natts * sizeof(ExprState *));
ri_GeneratedExprs = palloc0_array(ExprState *, natts);
ri_NumGeneratedNeeded = 0;
for (int i = 0; i < natts; i++)