From f644dc84949bcc6d6d06274a30feb4b366ae68de Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Tue, 11 Jun 2024 11:19:50 +0200 Subject: 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 Signed-off-by: Junio C Hamano --- notes.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'notes.c') diff --git a/notes.c b/notes.c index 6a157e34ce..244b5c4b1c 100644 --- a/notes.c +++ b/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; } } -- cgit 1.2.3-korg