Re: Avoid resource leak (src/bin/pg_dump/pg_dumpall.c) - Mailing list pgsql-hackers

From Michael Paquier
Subject Re: Avoid resource leak (src/bin/pg_dump/pg_dumpall.c)
Date
Msg-id aa5JyczrNPekXRrn@paquier.xyz
Whole thread Raw
In response to Re: Avoid resource leak (src/bin/pg_dump/pg_dumpall.c)  ("yangyz" <1197620467@qq.com>)
Responses Re: Avoid resource leak (src/bin/pg_dump/pg_dumpall.c)
Re: Avoid resource leak (src/bin/pg_dump/pg_dumpall.c)
List pgsql-hackers
On Mon, Mar 09, 2026 at 11:21:35AM +0800, yangyz wrote:
> I think it should be modified.
>
> Move createPQExpBuffer inside the conditional block to match its destroy counterpart.
> This improves code clarity and satisfies static analyzers, even though the actual memory
> leak is minimal in practice.

destroyPQExpBuffer() is called for each tuple from pg_database except
if dealing with "template{0,1}" or "postgres".  It means that we would
just leak a few bytes for these three cases.  I agree that the
variable declaration can be placed better, but it's really not worth
bothering in this context.
--
Michael

Attachment

pgsql-hackers by date:

Previous
From: Henson Choi
Date:
Subject: Re: Row pattern recognition
Next
From: vignesh C
Date:
Subject: Re: Skipping schema changes in publication