Skip to content

Commit c9be38c

Browse files
committed
fix(vec0): fix remaining memory leaks from PR asg017#258
- vec_eachFilter: free pzErrMsg on error to prevent leak - vec_slice: use goto done instead of return in INT8 and BIT cases to ensure vector cleanup is called on malloc failure These were the last 3 unfixed memory leaks from upstream PR asg017#258. The other 4 issues from that PR were already addressed in previous commits. Upstream-PR: asg017#258
1 parent 53aeaeb commit c9be38c

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

sqlite-vec.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1787,7 +1787,7 @@ static void vec_slice(sqlite3_context *context, int argc,
17871787
i8 *out = sqlite3_malloc(outSize);
17881788
if (!out) {
17891789
sqlite3_result_error_nomem(context);
1790-
return;
1790+
goto done;
17911791
}
17921792
memset(out, 0, outSize);
17931793
for (size_t i = 0; i < n; i++) {
@@ -1810,7 +1810,7 @@ static void vec_slice(sqlite3_context *context, int argc,
18101810
u8 *out = sqlite3_malloc(outSize);
18111811
if (!out) {
18121812
sqlite3_result_error_nomem(context);
1813-
return;
1813+
goto done;
18141814
}
18151815
memset(out, 0, outSize);
18161816
for (size_t i = 0; i < n / CHAR_BIT; i++) {
@@ -2677,6 +2677,7 @@ static int vec_eachFilter(sqlite3_vtab_cursor *pVtabCursor, int idxNum,
26772677
int rc = vector_from_value(argv[0], &pCur->vector, &pCur->dimensions,
26782678
&pCur->vector_type, &pCur->cleanup, &pzErrMsg);
26792679
if (rc != SQLITE_OK) {
2680+
sqlite3_free(pzErrMsg);
26802681
return SQLITE_ERROR;
26812682
}
26822683
pCur->iRowid = 0;

0 commit comments

Comments
 (0)