Skip to content

Commit 087ad7f

Browse files
committed
Fix: Free table_positions in sz_sequence_intersect_serial and _ice
Both intersect implementations allocated the linear-probing hash table via `alloc->allocate(...)` at function entry but never released it on the success path, leaking `hash_table_slots * (sizeof(sz_size_t) + sizeof(sz_u64_t))` bytes per call. LeakSanitizer flagged this as 6 direct leaks (~50 KiB total) in `test_intersecting_algorithms`. Add the missing `alloc->free(...)` before the final `return sz_success_k;` in each function. The `sz_bad_alloc_k` early return needs no free since the allocation itself failed.
1 parent a3926e2 commit 087ad7f

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

include/stringzilla/intersect.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,7 @@ SZ_PUBLIC sz_status_t sz_sequence_intersect_serial(
339339
}
340340
}
341341

342+
alloc->free(table_positions, hash_table_slots * bytes_per_entry, alloc);
342343
*intersection_count_ptr = intersection_count;
343344
return sz_success_k;
344345
}
@@ -721,6 +722,7 @@ SZ_PUBLIC sz_status_t sz_sequence_intersect_ice(
721722
}
722723

723724
// Finalize
725+
alloc->free(table_positions, hash_table_slots * bytes_per_entry, alloc);
724726
*intersection_count_ptr = intersection_count;
725727
return sz_success_k;
726728
}

0 commit comments

Comments
 (0)