From 6bd18462fe02520dc8a82aee01f70d1c5546e720 Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Tue, 3 Feb 2026 09:57:37 +1100 Subject: [PATCH v2] modify malloc in pg_dump_sort.c --- src/bin/pg_dump/pg_dump_sort.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/bin/pg_dump/pg_dump_sort.c b/src/bin/pg_dump/pg_dump_sort.c index 24bed6681de..03e5c1c1116 100644 --- a/src/bin/pg_dump/pg_dump_sort.c +++ b/src/bin/pg_dump/pg_dump_sort.c @@ -572,7 +572,7 @@ sortDumpableObjects(DumpableObject **objs, int numObjs, preDataBoundId = preBoundaryId; postDataBoundId = postBoundaryId; - ordering = (DumpableObject **) pg_malloc(numObjs * sizeof(DumpableObject *)); + ordering = pg_malloc_array(DumpableObject *, numObjs); while (!TopoSort(objs, numObjs, ordering, &nOrdering)) findDependencyLoops(ordering, nOrdering, numObjs); @@ -651,8 +651,8 @@ TopoSort(DumpableObject **objs, * We also make a map showing the input-order index of the item with * dumpId j. */ - beforeConstraints = (int *) pg_malloc0((maxDumpId + 1) * sizeof(int)); - idMap = (int *) pg_malloc((maxDumpId + 1) * sizeof(int)); + beforeConstraints = pg_malloc0_array(int, (maxDumpId + 1)); + idMap = pg_malloc_array(int, (maxDumpId + 1)); for (i = 0; i < numObjs; i++) { obj = objs[i]; @@ -787,9 +787,9 @@ findDependencyLoops(DumpableObject **objs, int nObjs, int totObjs) bool fixedloop; int i; - processed = (bool *) pg_malloc0((getMaxDumpId() + 1) * sizeof(bool)); - searchFailed = (DumpId *) pg_malloc0((getMaxDumpId() + 1) * sizeof(DumpId)); - workspace = (DumpableObject **) pg_malloc(totObjs * sizeof(DumpableObject *)); + processed = pg_malloc0_array(bool, (getMaxDumpId() + 1)); + searchFailed = pg_malloc0_array(DumpId, (getMaxDumpId() + 1)); + workspace = pg_malloc_array(DumpableObject *, totObjs); fixedloop = false; for (i = 0; i < nObjs; i++) -- 2.47.3