]> git.ipfire.org Git - thirdparty/git.git/commit
dir.c: free removed sparse-pattern hashmap entries
authorJeff King <peff@peff.net>
Tue, 4 Jun 2024 10:13:20 +0000 (06:13 -0400)
committerJunio C Hamano <gitster@pobox.com>
Tue, 4 Jun 2024 17:38:23 +0000 (10:38 -0700)
commit4c844c2f499a573e5801bd3cb83b8d42d3f1566a
tree4271682ffda424f861882fdf40f3bd4ff12b0904
parentdb83b64cda1813368e0c48b808c76422d4512b1b
dir.c: free removed sparse-pattern hashmap entries

In add_pattern_to_hashsets(), we remove entries from the
recursive_hashmap when adding similar ones to the parent_hashmap. I
won't pretend to understand all of what's going on here, but there's an
obvious leak: whatever we removed from recursive_hashmap is not
referenced anywhere else, and is never free()d.

We can easily fix this by asking the hashmap to return a pointer to the
old entry. This makes t7002 now completely leak-free.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
dir.c
t/t7002-mv-sparse-checkout.sh