pgsql: Fix minor memory leaks in pg_dump.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix minor memory leaks in pg_dump.
Date: 2021-10-24 16:39:04
Message-ID: E1megWW-0001DE-Fx@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix minor memory leaks in pg_dump.

I found these by running pg_dump under "valgrind --leak-check=full".

The changes in flagInhIndexes() and getIndexes() replace allocation of
an array of which we use only some elements by individual allocations
of just the actually-needed objects. The previous coding wasted some
memory, but more importantly it confused valgrind's leak tracking.

collectComments() and collectSecLabels() remain major blots on
the valgrind report, because they don't PQclear their query
results, in order to avoid a lot of strdup's. That's a dubious
tradeoff, but I'll leave it alone here; an upcoming patch will
modify those functions enough to justify changing the tradeoff.

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/70bef494000e4dbbeca0f0a40347ca1747aea701

Modified Files
--------------
src/bin/pg_dump/common.c | 42 ++++++++++++------------
src/bin/pg_dump/pg_backup_archiver.c | 2 ++
src/bin/pg_dump/pg_dump.c | 63 +++++++++++++++++++-----------------
3 files changed, 56 insertions(+), 51 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Michael Paquier 2021-10-24 22:42:13 pgsql: Add replication command READ_REPLICATION_SLOT
Previous Message Andrew Dunstan 2021-10-24 14:44:39 pgsql: Move Perl test modules to a better namespace