mirror of
https://github.com/asg017/sqlite-vec.git
synced 2026-04-25 00:36:56 +02:00
Add NULL checks after sqlite3_column_blob in rescore and DiskANN
sqlite3_column_blob() returns NULL for zero-length blobs or on OOM. Several call sites in rescore KNN and DiskANN node/vector read passed the result directly to memcpy without checking, risking NULL deref on corrupt or empty databases. IVF already had proper NULL checks. Adds corruption regression tests that truncate shadow table blobs and verify the query errors cleanly instead of crashing. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
9df59b4c03
commit
82f4eb08bf
4 changed files with 76 additions and 4 deletions
|
|
@ -426,6 +426,10 @@ static int rescore_knn(vec0_vtab *p, vec0_cursor *pCur,
|
|||
unsigned char *chunkValidity =
|
||||
(unsigned char *)sqlite3_column_blob(stmtChunks, 1);
|
||||
i64 *chunkRowids = (i64 *)sqlite3_column_blob(stmtChunks, 2);
|
||||
if (!chunkValidity || !chunkRowids) {
|
||||
rc = SQLITE_ERROR;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
memset(chunk_distances, 0, p->chunk_size * sizeof(f32));
|
||||
memset(chunk_topk_idxs, 0, k_oversample * sizeof(i32));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue