diff options
author | Junio C Hamano <gitster@pobox.com> | 2024-07-08 14:53:10 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2024-07-08 14:53:10 -0700 |
commit | 3997614c249b4b475d07c00556446d8b698d1a49 (patch) | |
tree | fc0d71d047b303ec2b25fd0711069e9ba4751dd9 /notes-utils.c | |
parent | ecf7fc600a5218c9ee3863ee70d5a6e312164f30 (diff) | |
parent | fbf7a46d881429ef5495af7bbf3a6c3dacbf80b3 (diff) |
Merge branch 'ps/leakfixes-more'
More memory leaks have been plugged.
* ps/leakfixes-more: (29 commits)
builtin/blame: fix leaking ignore revs files
builtin/blame: fix leaking prefixed paths
blame: fix leaking data for blame scoreboards
line-range: plug leaking find functions
merge: fix leaking merge bases
builtin/merge: fix leaking `struct cmdnames` in `get_strategy()`
sequencer: fix memory leaks in `make_script_with_merges()`
builtin/clone: plug leaking HEAD ref in `wanted_peer_refs()`
apply: fix leaking string in `match_fragment()`
sequencer: fix leaking string buffer in `commit_staged_changes()`
commit: fix leaking parents when calling `commit_tree_extended()`
config: fix leaking "core.notesref" variable
rerere: fix various trivial leaks
builtin/stash: fix leak in `show_stash()`
revision: free diff options
builtin/log: fix leaking commit list in git-cherry(1)
merge-recursive: fix memory leak when finalizing merge
builtin/merge-recursive: fix leaking object ID bases
builtin/difftool: plug memory leaks in `run_dir_diff()`
object-name: free leaking object contexts
...
Diffstat (limited to 'notes-utils.c')
-rw-r--r-- | notes-utils.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/notes-utils.c b/notes-utils.c index bca71274be..ac66b82dd3 100644 --- a/notes-utils.c +++ b/notes-utils.c @@ -11,10 +11,11 @@ void create_notes_commit(struct repository *r, struct notes_tree *t, - struct commit_list *parents, + const struct commit_list *parents, const char *msg, size_t msg_len, struct object_id *result_oid) { + struct commit_list *parents_to_free = NULL; struct object_id tree_oid; assert(t->initialized); @@ -29,7 +30,8 @@ void create_notes_commit(struct repository *r, struct commit *parent = lookup_commit(r, &parent_oid); if (repo_parse_commit(r, parent)) die("Failed to find/parse commit %s", t->ref); - commit_list_insert(parent, &parents); + commit_list_insert(parent, &parents_to_free); + parents = parents_to_free; } /* else: t->ref points to nothing, assume root/orphan commit */ } @@ -37,6 +39,8 @@ void create_notes_commit(struct repository *r, if (commit_tree(msg, msg_len, &tree_oid, parents, result_oid, NULL, NULL)) die("Failed to commit notes tree to database"); + + free_commit_list(parents_to_free); } void commit_notes(struct repository *r, struct notes_tree *t, const char *msg) @@ -189,6 +193,7 @@ void finish_copy_notes_for_rewrite(struct repository *r, for (i = 0; c->trees[i]; i++) { commit_notes(r, c->trees[i], msg); free_notes(c->trees[i]); + free(c->trees[i]); } free(c->trees); free(c); |