From 38d16a82eb4a8b0e393b51cc3e9144dc7b413fd1 Mon Sep 17 00:00:00 2001 From: Vitah Lin Date: Thu, 28 Aug 2025 21:17:55 +0800 Subject: [PATCH] Fix missing prev update in hnsw_cursor_free causing unlink failure (#14050) This PR fixes a bug in the `hnsw_cursor_free` function where the prev pointer was never updated during cursor list traversal. As a result, if the cursor being freed was not the head of the list, it would not be correctly unlinked, potentially causing memory leaks or corruption of the cursor list. Note that since `hnsw_cursor_free()` is never used for now, this PR does not actually fix any bug. --- modules/vector-sets/hnsw.c | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/vector-sets/hnsw.c b/modules/vector-sets/hnsw.c index cae43e305..9895522f8 100644 --- a/modules/vector-sets/hnsw.c +++ b/modules/vector-sets/hnsw.c @@ -2489,6 +2489,7 @@ void hnsw_cursor_free(hnswCursor *cursor) { hfree(cursor); break; } + prev = x; x = x->next; } pthread_rwlock_unlock(&cursor->index->global_lock);