Re: Fix a resource leak (src/backend/utils/adt/rowtypes.c)

From: Ranier Vilela <ranier(dot)vf(at)gmail(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Fix a resource leak (src/backend/utils/adt/rowtypes.c)
Date: 2025-04-14 20:49:39
Message-ID: CAEudQArvbWEr4cbbxqEVOJsSBaUwV0J5FaMcSxgXyr46qJEsyQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Em seg., 14 de abr. de 2025 às 16:59, Robert Haas <robertmhaas(at)gmail(dot)com>
escreveu:

> On Sun, Apr 13, 2025 at 7:34 PM Ranier Vilela <ranier(dot)vf(at)gmail(dot)com> wrote:
> > CID 1608916: (#1 of 1): Resource leak (RESOURCE_LEAK)
> > 52. leaked_storage: Variable buf going out of scope leaks the storage
> buf.data points to.
> >
> > The function *record_in* has a new report about resource leak.
> > I think Coverity is right.
>
> I agree, for small values of "right".

Thanks.

> The memory isn't formally leaked
> because it will be eventually released when the containing memory
> context is deleted, but it's unclear why we should bother to clean up
> the memory in the normal path yet skip it here. I wondered whether the
> existing pfree calls were added in response to some specific
> complaint, but it doesn't appear so: they date back to Tom's 2004-era
> commit a3704d3deca6d08013a6b1db0432b75dc6b78d28,

Thanks for researching.

> the commit message
> for which is rather more brief than what is typical today. Still, it
> seems safer to bet on the pfree being a good idea than on the reverse,
> because record_in() can be called lots of times in a single
> transaction.
>
I think that material for v18, although there were no reported concerns.

best regards,
Ranier Vilela

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Noah Misch 2025-04-14 20:52:52 Re: Call for Posters: PGConf.dev 2025
Previous Message Noah Misch 2025-04-14 20:44:08 Re: [18] Unintentional behavior change in commit e9931bfb75