Fix memory leak in gist_page_items() of pageinspect
Chao Li <li.evan.chao@gmail.com>
From: Chao Li <li.evan.chao@gmail.com>
To: Postgres hackers <pgsql-hackers@lists.postgresql.org>
Date: 2025-12-12T08:50:09Z
Lists: pgsql-hackers
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Use relation_close() more consistently in contrib/
- 8b9b93e39b10 19 (unreleased) landed
-
Use table/index_close() more consistently
- 9d0f7996e58c 19 (unreleased) landed
-
pageinspect: use index_close() for GiST index relation
- 171198ff2a57 19 (unreleased) landed
Attachments
- v1-0001-Fix-memory-leak-in-gist_page_items.patch (application/octet-stream) patch v1-0001
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/