Skip to content

Commit ca00f19

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 33e111f commit ca00f19

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
Original file line numberDiff line numberDiff line change
@@ -226,14 +226,17 @@ gistendscan(PG_FUNCTION_ARGS)
226226
gistfreestack(so->stack);
227227
gistfreestack(so->markstk);
228228
if (so->giststate != NULL)
229+
{
229230
freeGISTstate(so->giststate);
231+
pfree(so->giststate);
232+
}
230233
/* drop pins on buffers -- we aren't holding any locks */
231234
if (BufferIsValid(so->curbuf))
232235
ReleaseBuffer(so->curbuf);
233236
if (BufferIsValid(so->markbuf))
234237
ReleaseBuffer(so->markbuf);
235238
MemoryContextDelete(so->tempCxt);
236-
pfree(scan->opaque);
239+
pfree(so);
237240
}
238241

239242
PG_RETURN_VOID();

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy