Skip to content

Commit

Permalink
fix segfault on invalid vec_each() input, fixes #163
Browse files Browse the repository at this point in the history
  • Loading branch information
asg017 committed Jan 10, 2025
1 parent 21eda5c commit 44e4438
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion sqlite-vec.c
Original file line number Diff line number Diff line change
Expand Up @@ -2483,7 +2483,9 @@ static int vec_eachOpen(sqlite3_vtab *p, sqlite3_vtab_cursor **ppCursor) {

static int vec_eachClose(sqlite3_vtab_cursor *cur) {
vec_each_cursor *pCur = (vec_each_cursor *)cur;
pCur->cleanup(pCur->vector);
if(pCur->vector) {
pCur->cleanup(pCur->vector);
}
sqlite3_free(pCur);
return SQLITE_OK;
}
Expand Down
3 changes: 3 additions & 0 deletions tests/test-loadable.py
Original file line number Diff line number Diff line change
Expand Up @@ -1614,6 +1614,9 @@ def test_vec_each():
{"rowid": 2, "value": 3.0},
]

with _raises("Input must have type BLOB (compact format) or TEXT (JSON), found NULL"):
vec_each_f32(None)


import io

Expand Down

0 comments on commit 44e4438

Please sign in to comment.