From 5f5621adfe5191d36a371a5d975d546776cf659d Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Tue, 3 Feb 2026 12:24:03 +1100 Subject: [PATCH v2] modify more mallocs in pg_dump.c --- src/bin/pg_dump/pg_dump.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c index 0b78d620ba6..348a5238dc9 100644 --- a/src/bin/pg_dump/pg_dump.c +++ b/src/bin/pg_dump/pg_dump.c @@ -1556,7 +1556,7 @@ setup_connection(Archive *AH, const char *dumpencoding, * Initialize prepared-query state to "nothing prepared". We do this here * so that a parallel dump worker will have its own state. */ - AH->is_prepared = (bool *) pg_malloc0(NUM_PREP_QUERIES * sizeof(bool)); + AH->is_prepared = pg_malloc0_array(bool, NUM_PREP_QUERIES); /* * Start transaction-snapshot mode transaction to dump consistent data. @@ -7057,7 +7057,7 @@ getFuncs(Archive *fout) ntups = PQntuples(res); - finfo = (FuncInfo *) pg_malloc0(ntups * sizeof(FuncInfo)); + finfo = pg_malloc0_array(FuncInfo, ntups); i_tableoid = PQfnumber(res, "tableoid"); i_oid = PQfnumber(res, "oid"); @@ -7134,7 +7134,7 @@ getRelationStatistics(Archive *fout, DumpableObject *rel, int32 relpages, (relkind == RELKIND_MATVIEW || relkind == RELKIND_FOREIGN_TABLE)) { - RelStatsInfo *info = pg_malloc0(sizeof(RelStatsInfo)); + RelStatsInfo *info = pg_malloc0_object(RelStatsInfo); DumpableObject *dobj = &info->dobj; dobj->objType = DO_REL_STATS; @@ -7426,7 +7426,7 @@ getTables(Archive *fout, int *numTables) * only one, because we don't yet know which tables might be inheritance * ancestors of the target table. */ - tblinfo = (TableInfo *) pg_malloc0(ntups * sizeof(TableInfo)); + tblinfo = pg_malloc0_array(TableInfo, ntups); i_reltableoid = PQfnumber(res, "tableoid"); i_reloid = PQfnumber(res, "oid"); @@ -19281,7 +19281,7 @@ dumpSequence(Archive *fout, const TableInfo *tbinfo) PQntuples(res)), tbinfo->dobj.name, PQntuples(res)); - seq = pg_malloc0(sizeof(SequenceItem)); + seq = pg_malloc0_object(SequenceItem); seq->seqtype = parse_sequence_type(PQgetvalue(res, 0, 0)); seq->startv = strtoi64(PQgetvalue(res, 0, 1), NULL, 10); seq->incby = strtoi64(PQgetvalue(res, 0, 2), NULL, 10); -- 2.47.3