pg_dump: Fix memory leak in dumpSequenceData().
authorNathan Bossart <nathan@postgresql.org>
Sun, 11 Jan 2026 19:52:50 +0000 (13:52 -0600)
committerNathan Bossart <nathan@postgresql.org>
Sun, 11 Jan 2026 19:52:50 +0000 (13:52 -0600)
Oversight in commit 7a485bd641.  Per Coverity.

Backpatch-through: 18

src/bin/pg_dump/pg_dump.c

index b9e0edf8755122485a3937ef67d4a8a681cfbcd8..328a1bad21b30bd9f68e2b21133ae1f7797054c7 100644 (file)
@@ -19230,12 +19230,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()