Fix memory leak in gist_page_items() of pageinspect - Mailing list pgsql-hackers

From Chao Li
Subject Fix memory leak in gist_page_items() of pageinspect
Date
Msg-id CAEoWx2=bL41WWcD-4Fxx-buS2Y2G5=9PjkxZbHeFMR6Uy2WNvw@mail.gmail.com
Whole thread Raw
Responses Re: Fix memory leak in gist_page_items() of pageinspect
List pgsql-hackers
Hi Hackers,

While reading the code of pageinspect, I just found a memory leak in gist_page_items():

```
   values[4] = CStringGetTextDatum(buf.data);
   nulls[4] = false;
```

where CStringGetTextDatum() has made a copy of buf.data and assigned to value[4], however buf.data is never free-ed. This leak is inside a per-tuple loop, thus it should be fixed.

In the meantime, the other small issue was also found in the same function. An index is opened by index_open() but closed by index_close() and relation_close() in different places. I also fixed the problem by changing relation_close() to index_close().

Best regards,
==
Chao Li (Evan)
---------------------
HighGo Software Co., Ltd.
https://www.highgo.com/
Attachment

pgsql-hackers by date:

Previous
From: Bertrand Drouvot
Date:
Subject: Re: Fix and improve allocation formulas
Next
From: Heikki Linnakangas
Date:
Subject: Re: POC: make mxidoff 64 bits