mirror of
https://github.com/git/git
synced 2024-09-29 21:27:13 +00:00
notes: fix memory leak when pruning notes
In `prune_notes()` we first store the notes that are to be deleted in a local list, and then iterate through that list to delete those notes one by one. We never free the list though and thus leak its memory. Fix this. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
9748537437
commit
f644dc8494
7
notes.c
7
notes.c
|
@ -1219,11 +1219,16 @@ void prune_notes(struct notes_tree *t, int flags)
|
|||
for_each_note(t, 0, prune_notes_helper, &l);
|
||||
|
||||
while (l) {
|
||||
struct note_delete_list *next;
|
||||
|
||||
if (flags & NOTES_PRUNE_VERBOSE)
|
||||
printf("%s\n", hash_to_hex(l->sha1));
|
||||
if (!(flags & NOTES_PRUNE_DRYRUN))
|
||||
remove_note(t, l->sha1);
|
||||
l = l->next;
|
||||
|
||||
next = l->next;
|
||||
free(l);
|
||||
l = next;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
test_description='Test git notes prune'
|
||||
|
||||
TEST_PASSES_SANITIZE_LEAK=true
|
||||
. ./test-lib.sh
|
||||
|
||||
test_expect_success 'setup: create a few commits with notes' '
|
||||
|
|
Loading…
Reference in a new issue