pgvector.git / summary / log / commit / refs
commit 93a5b4a16d699eaf890970777c19f19b9d545782
Author: zthhhhh <97zthhhh@gamil.com>
Commit: Andrew Kane <andrew@ankane.org>
Date: Mon Jul 27 10:13:21 2026 +0000
Fix memory leak in ivfrescan
src/ivfscan.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/src/ivfscan.c b/src/ivfscan.c
index 00aad285..f9cd2488 100644
--- a/src/ivfscan.c
+++ b/src/ivfscan.c
@@ -282,6 +282,7 @@ ivfflatbeginscan(Relation index, int nkeys, int norderbys)
so->probes = probes;
so->maxProbes = maxProbes;
so->dimensions = dimensions;
+ so->value = PointerGetDatum(NULL);
/* Set support functions */
so->procinfo = index_getprocinfo(index, 1, IVFFLAT_DISTANCE_PROC);
@@ -340,6 +341,12 @@ ivfflatrescan(IndexScanDesc scan, ScanKey keys, int nkeys, ScanKey orderbys, int
pairingheap_reset(so->listQueue);
so->listIndex = 0;
+ if (so->normprocinfo != NULL && DatumGetPointer(so->value) != NULL)
+ {
+ pfree(DatumGetPointer(so->value));
+ so->value = PointerGetDatum(NULL);
+ }
+
if (keys && scan->numberOfKeys > 0)
memmove(scan->keyData, keys, scan->numberOfKeys * sizeof(ScanKeyData));
[parent: c0919bc26ae7]