pgvector.git / summary / log / commit / refs

commit    dc4a79a7e7031f951d403af5b8a39a759cc60894
Author:   Andrew Kane <andrew@ankane.org>
Date:     Sun Oct 30 19:01:24 2022 +0000

    Added check for indexing overflow


src/ivfkmeans.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/ivfkmeans.c b/src/ivfkmeans.c index 99879831..7f205a74 100644 --- a/src/ivfkmeans.c +++ b/src/ivfkmeans.c @@ -204,6 +204,9 @@ ElkanKmeans(Relation index, VectorArray samples, VectorArray centers) double dxcx; double dxc; + /* Ensure indexing does not overflow */ + Assert(numCenters * numCenters <= INT_MAX); + /* Calculate allocation sizes */ Size samplesSize = VECTOR_ARRAY_SIZE(samples->maxlen, samples->dim); Size centersSize = VECTOR_ARRAY_SIZE(centers->maxlen, centers->dim); [parent: 1652a130c55d]