Skip to content

Commit 5e4c557

Browse files
asg017claude
andcommitted
Initialize rescore distance variable to FLT_MAX
The `dist` variable in rescore KNN quantized distance computation was uninitialized. If the switch on quantizer_type or distance_metric didn't match any case, the uninitialized value would propagate into the top-k heap, potentially returning garbage results. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 82f4eb0 commit 5e4c557

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎sqlite-vec-rescore.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ static int rescore_knn(vec0_vtab *p, vec0_cursor *pCur,
465465
for (int j = 0; j < p->chunk_size; j++) {
466466
if (!bitmap_get(b, j))
467467
continue;
468-
f32 dist;
468+
f32 dist = FLT_MAX;
469469
switch (vector_column->rescore.quantizer_type) {
470470
case VEC0_RESCORE_QUANTIZER_BIT: {
471471
const u8 *base_j = ((u8 *)baseVectors) + (j * (qdim / CHAR_BIT));

0 commit comments

Comments
 (0)