diff options
author | Patrick Steinhardt <ps@pks.im> | 2024-06-11 11:19:50 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2024-06-11 13:15:05 -0700 |
commit | f644dc84949bcc6d6d06274a30feb4b366ae68de (patch) | |
tree | 575d800735a9687ed89c1e0f7c4c33a91382c0ce /notes.c | |
parent | 97485374377fa62fdd36f4b707e2fcd8f1a7c6c3 (diff) |
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>
Diffstat (limited to 'notes.c')
-rw-r--r-- | notes.c | 7 |
1 files changed, 6 insertions, 1 deletions
@@ -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; } } |