From 56e1f501010fc79fd1d11df6fd04eec463d40319 Mon Sep 17 00:00:00 2001 From: Nathan Bossart Date: Sun, 11 Jan 2026 13:52:50 -0600 Subject: [PATCH] pg_dump: Fix memory leak in dumpSequenceData(). Oversight in commit 7a485bd641. Per Coverity. Backpatch-through: 18 --- src/bin/pg_dump/pg_dump.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c index b00ba35f87c..583afc67d3f 100644 --- a/src/bin/pg_dump/pg_dump.c +++ b/src/bin/pg_dump/pg_dump.c @@ -19056,12 +19056,14 @@ dumpSequenceData(Archive *fout, const TableDataInfo *tdinfo) TableInfo *tbinfo = tdinfo->tdtable; int64 last; bool called; - PQExpBuffer query = createPQExpBuffer(); + PQExpBuffer query; /* needn't bother if not dumping sequence data */ if (!fout->dopt->dumpData && !fout->dopt->sequence_data) return; + query = createPQExpBuffer(); + /* * For versions >= 18, the sequence information is gathered in the sorted * array before any calls to dumpSequenceData(). See collectSequences() -- 2.47.3