Skip to content

Commit 14ff4c9

Browse files
committed
Added check for text length
1 parent 716f3ed commit 14ff4c9

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

include/pgvector/pqxx.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ template <> struct string_traits<pgvector::Vector> {
3131
static constexpr bool converts_from_string{true};
3232

3333
static pgvector::Vector from_string(std::string_view text) {
34-
if (text.front() != '[' || text.back() != ']') {
34+
if (text.size() < 2 || text.front() != '[' || text.back() != ']') {
3535
throw conversion_error("Malformed vector literal");
3636
}
3737

@@ -76,7 +76,7 @@ template <> struct string_traits<pgvector::HalfVector> {
7676
static constexpr bool converts_from_string{true};
7777

7878
static pgvector::HalfVector from_string(std::string_view text) {
79-
if (text.front() != '[' || text.back() != ']') {
79+
if (text.size() < 2 || text.front() != '[' || text.back() != ']') {
8080
throw conversion_error("Malformed halfvec literal");
8181
}
8282

0 commit comments

Comments
 (0)