diff options
author | Patrick Steinhardt <ps@pks.im> | 2024-06-11 11:20:42 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2024-06-11 22:15:07 +0200 |
commit | 63c9bd372e388f5fed77be56771d5ad972f37f8e (patch) | |
tree | 70f1e32515bb7b1142f310ef9995a30e19859044 /notes-utils.h | |
parent | config: fix leaking "core.notesref" variable (diff) | |
download | git-63c9bd372e388f5fed77be56771d5ad972f37f8e.tar.xz git-63c9bd372e388f5fed77be56771d5ad972f37f8e.zip |
commit: fix leaking parents when calling `commit_tree_extended()`
When creating commits via `commit_tree_extended()`, the caller passes in
a string list of parents. This call implicitly transfers ownership of
that list to the function, which is quite surprising to begin with. But
to make matters worse, `commit_tree_extended()` doesn't even bother to
free the list of parents in error cases. The result is a memory leak,
and one that the caller cannot fix by themselves because they do not
know whether parts of the string list have already been released.
Refactor the code such that callers can keep ownership of the list of
parents, which is getting indicated by parameter being a constant
pointer now. Free the lists at the calling site and add a common exit
path to those sites as required.
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'notes-utils.h')
-rw-r--r-- | notes-utils.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/notes-utils.h b/notes-utils.h index d9b3c09eaf..c54b1fe141 100644 --- a/notes-utils.h +++ b/notes-utils.h @@ -20,7 +20,7 @@ struct repository; */ 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); |