Re: Avoid resource leak (src/bin/pg_dump/pg_dumpall.c)

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: yangyz <1197620467(at)qq(dot)com>
Cc: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>, Ranier Vilela <ranier(dot)vf(at)gmail(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Avoid resource leak (src/bin/pg_dump/pg_dumpall.c)
Date: 2026-03-09 04:17:13
Message-ID: aa5JyczrNPekXRrn@paquier.xyz
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message vignesh C 2026-03-09 04:32:26 Re: Skipping schema changes in publication
Previous Message Henson Choi 2026-03-09 04:02:02 Re: Row pattern recognition