hashindex: fix memory leak, fixes #9497

Thanks to @rolandrc for finding and fixing this!

Also: set index->buckets = NULL to indicate "we are finished with this" and avoid use-after-free.
This commit is contained in:
Thomas Waldmann 2026-03-17 19:03:03 +01:00
parent 56986f3d58
commit 8eb8779023
No known key found for this signature in database
GPG key ID: 243ACFA951F78E01

View file

@ -131,11 +131,13 @@ hashindex_free_buckets(HashIndex *index)
#ifndef BORG_NO_PYTHON
if(index->buckets_buffer.buf) {
PyBuffer_Release(&index->buckets_buffer);
index->buckets_buffer.buf = NULL;
} else
#endif
{
free(index->buckets);
}
index->buckets = NULL;
}
static int