Re: Fix memory leak in gist_page_items() of pageinspect

Bertrand Drouvot <bertranddrouvot.pg@gmail.com>

From: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
To: Michael Paquier <michael@paquier.xyz>
Cc: Chao Li <li.evan.chao@gmail.com>, Postgres hackers <pgsql-hackers@lists.postgresql.org>
Date: 2025-12-12T10:23:48Z
Lists: pgsql-hackers
Hi,

On Fri, Dec 12, 2025 at 06:48:09PM +0900, Michael Paquier wrote:
> On Fri, Dec 12, 2025 at 09:00:08AM +0000, Bertrand Drouvot wrote:
> > On Fri, Dec 12, 2025 at 04:50:09PM +0800, Chao Li wrote:
> >> where CStringGetTextDatum() has made a copy of buf.data and assigned to
> >> value[4], however buf.data is never free-ed.
> > 
> > I did not look in details but I think that we should be in a short lived
> > memory context here so we generally prefer to avoid using pfree for those cases.
> 
> The only thing that does a memory allocation is the StringInfo, why
> would a memory context be worth the complication here?

I meant to say: we are probably already in a short lived memory context. I did
not mean to say to switch to a new one.

Regards,

-- 
Bertrand Drouvot
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com