File tree Expand file tree Collapse file tree 2 files changed +5
-1
lines changed
Expand file tree Collapse file tree 2 files changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -200,7 +200,7 @@ template<> struct string_traits<pgvector::SparseVector> {
200200 int index = pqxx::from_string<int >(substr.substr (0 , ne), c);
201201 float value = pqxx::from_string<float >(substr.substr (ne + 1 ), c);
202202
203- if (index < 1 ) {
203+ if (index < 1 || index > dimensions ) {
204204 throw conversion_error{" Index out of bounds" };
205205 }
206206
Original file line number Diff line number Diff line change @@ -264,6 +264,10 @@ void test_sparsevec_from_string() {
264264 auto _ = pqxx::from_string<pgvector::SparseVector>(" {-2147483648:1}/1" );
265265 }, " Index out of bounds" );
266266
267+ assert_exception<pqxx::conversion_error>([] {
268+ auto _ = pqxx::from_string<pgvector::SparseVector>(" {2:1}/1" );
269+ }, " Index out of bounds" );
270+
267271 assert_exception<pqxx::conversion_error>([] {
268272 auto _ = pqxx::from_string<pgvector::SparseVector>(" {1:4e38}/1" );
269273 }, float_error (" Could not convert '4e38' to float: Value out of range." ));
You can’t perform that action at this time.
0 commit comments