Skip to content

Commit 35ce275

Browse files
maplenkclaude
andcommitted
Fix ASan leak in test_algorithms: free node fields after find_node calls
The test helpers cbm_store_find_node_by_id/qn heap-allocate string fields via scan_node, but 6 call sites in test_algorithms.c never freed them. Linux ASan (detect_leaks=1) caught 412 bytes leaked in 36 allocations. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 9c4c38a commit 35ce275

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

tests/test_algorithms.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ TEST(pagerank_basic) {
9898
ASSERT_EQ(rc, CBM_STORE_OK);
9999
ASSERT_GT(d.id, 0);
100100

101+
cbm_node_free_fields(&d);
101102
cbm_store_close(s);
102103
PASS();
103104
}
@@ -195,6 +196,7 @@ TEST(ppr_basic) {
195196

196197
free(out_ids);
197198
free(out_scores);
199+
cbm_node_free_fields(&a);
198200
cbm_store_close(s);
199201
PASS();
200202
}
@@ -229,6 +231,8 @@ TEST(ppr_multiple_seeds) {
229231

230232
free(out_ids);
231233
free(out_scores);
234+
cbm_node_free_fields(&a);
235+
cbm_node_free_fields(&b);
232236
cbm_store_close(s);
233237
PASS();
234238
}
@@ -290,6 +294,7 @@ TEST(fts_search_by_name) {
290294
ASSERT_EQ(rc, CBM_STORE_OK);
291295
ASSERT(strstr(found.name, "processOrder") != NULL || strstr(found.qualified_name, "processOrder") != NULL);
292296

297+
cbm_node_free_fields(&found);
293298
free(ids);
294299
free(scores);
295300
cbm_store_close(s);
@@ -315,6 +320,7 @@ TEST(fts_search_by_path) {
315320
cbm_store_find_node_by_id(s, ids[0], &found);
316321
ASSERT(strstr(found.file_path, "payment") != NULL || strstr(found.name, "Payment") != NULL);
317322

323+
cbm_node_free_fields(&found);
318324
free(ids);
319325
free(scores);
320326
cbm_store_close(s);

0 commit comments

Comments
 (0)