Re: Memory leak fixes for pg_dump, pg_dumpall, initdb and pg_upgrade

From: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
To: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>, PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Memory leak fixes for pg_dump, pg_dumpall, initdb and pg_upgrade
Date: 2015-07-02 18:14:37
Message-ID: 55957F8D.8080400@iki.fi
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 06/08/2015 09:48 AM, Michael Paquier wrote:
> Hi all,
>
> Please find attached a set of fixes for a couple of things in src/bin:
> - pg_dump/pg_dumpall:
> -- getFormattedTypeName, convertTSFunction and myFormatType return
> strdup'd results that are never free'd.
> -- convertTSFunction returns const char. I fail to see the point of
> that... In my opinion we are fine with just returning a char pointer,
> which is strdup'd so as it can be freed by the caller.
> - initdb's and pg_regress' use getaddrinfo, but do not free the
> returned result with freeaddrinfo().
> - Coverity noticed on the way some leaked memory in pg_upgrade's
> equivalent_locale().
>
> Those issues have been mostly spotted by Coverity, I may have spotted
> some of them while looking at similar code paths... In any case that's
> Coverity's win ;)

"Fixing" most of these is not really an improvement, IMO. They're in
pg_dump and pg_ugprade, which you only run once and then it exits, so as
long as the leaks are not in some tight loops that execute millions of
time, it doesn't matter.

I committed some of these that seemed like improvements on readability
grounds, but please just mark the rest as "ignore" in coverity.

- Heikki

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2015-07-02 18:17:16 Re: Reducing ClogControlLock contention
Previous Message Josh Berkus 2015-07-02 18:10:27 Re: Support for N synchronous standby servers - take 2