8000 gistendscan() forgot to free so->giststate. · jaylevitt/postgres@9bc6daa · GitHub
[go: up one dir, main page]

Skip to content

Commit 9bc6daa

Browse files
committed
gistendscan() forgot to free so->giststate.
This oversight led to a massive memory leak --- upwards of 10KB per tuple --- during creation-time verification of an exclusion constraint based on a GIST index. In most other scenarios it'd just be a leak of 10KB that would be recovered at end of query, so not too significant; though perhaps the leak would be noticeable in a situation where a GIST index was being used in a nestloop inner indexscan. In any case, it's a real leak of long standing, so patch all supported branches. Per report from Harald Fuchs.
1 parent 5d68fe1 commit 9bc6daa

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/backend/access/gist/gistscan.c

Lines changed: 4 additions & 1 deletion
< 87DC td data-grid-cell-id="diff-a94db1a641c0b691772ef0054223f4aed7fcd6b18c47077349a9a3084f2b8e18-136-136-1" data-selected="false" role="gridcell" style="background-color:var(--bgColor-default);text-align:center" tabindex="-1" valign="top" class="focusable-grid-cell diff-line-number position-relative diff-line-number-neutral left-side">136
Original file line numberDiff line numberDiff line change
@@ -135,12 +135,15 @@ gistendscan(PG_FUNCTION_ARGS)
135135
{
136
gistfreestack(so->stack);
137137
if (so->giststate != NULL)
138+
{
138139
freeGISTstate(so->giststate);
140+
pfree(so->giststate);
141+
}
139142
/* drop pins on buffers -- we aren't holding any locks */
140143
if (BufferIsValid(so->curbuf))
141144
ReleaseBuffer(so->curbuf);
142145
MemoryContextDelete(so->tempCxt);
143-
pfree(scan->opaque);
146+
pfree(so);
144147
}
145148

146149
PG_RETURN_VOID();

0 commit comments

Comments
 (0)
0