pg.ddx.io pgvector/pgvector GitHub issues and pull requests
help / color / mirror / Atom feedFrom: lyinglyingl (@lyinglyingl) <noreply+lyinglyingl@github.com>
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
Subject: [pgvector/pgvector] PR #1016: fix sparsevec_to_vector: add index bounds check to prevent out‑of‑bou…
Date: Wed, 12 Aug 2026 09:27:24 +0000
Message-ID: <gh-pgvector-pgvector-1016@github.com> (raw)
…nds access
inline patch 1: src/vector.c (+5/-0 lines) download inline-1.patch
diff --git a/src/vector.c b/src/vector.c
index b75cfc4b7..447b045fe 100644
--- a/src/vector.c
+++ b/src/vector.c
@@ -1329,7 +1329,12 @@ sparsevec_to_vector(PG_FUNCTION_ARGS)
result = InitVector(dim);
for (int i = 0; i < svec->nnz; i++)
+ {
+ if (svec->indices[i] < 0 || svec->indices[i] >= dim)
+ ereport(ERROR, (errcode(ERRCODE_DATA_EXCEPTION),
+ errmsg("sparsevec index out of bounds")));
result->x[svec->indices[i]] = values[i];
+ }
PG_RETURN_POINTER(result);
}
view thread (4+ messages) latest in thread
Message-ID: <gh-pgvector-pgvector-1016@github.com>
Permalink: ../gh-pgvector-pgvector-1016@github.com/
· ·
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox