From 5df07b51ef212c8f57b11b2638de7ae5e4b51877 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Tue, 17 Mar 2026 19:03:03 +0100 Subject: [PATCH] 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. --- src/borg/_hashindex.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/borg/_hashindex.c b/src/borg/_hashindex.c index afadb23e1..e02bd665a 100644 --- a/src/borg/_hashindex.c +++ b/src/borg/_hashindex.c @@ -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