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:

committed by
Junio C Hamano

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;
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user