| From: | Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com> |
|---|---|
| To: | Postgres hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Subject: | Fix memory leak in gist_page_items() of pageinspect |
| Date: | 2025-12-12 08:50:09 |
| Message-ID: | CAEoWx2=bL41WWcD-4Fxx-buS2Y2G5=9PjkxZbHeFMR6Uy2WNvw@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | 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 | Content-Type | Size |
|---|---|---|
| v1-0001-Fix-memory-leak-in-gist_page_items.patch | application/octet-stream | 1.3 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Heikki Linnakangas | 2025-12-12 08:51:25 | Re: POC: make mxidoff 64 bits |
| Previous Message | Bertrand Drouvot | 2025-12-12 08:46:52 | Re: Fix and improve allocation formulas |