diff options
author | Junio C Hamano <gitster@pobox.com> | 2022-08-25 23:42:31 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2022-08-25 23:42:31 +0200 |
commit | 01a30a5a58053ce74a551a42d9edb2cf4f95632b (patch) | |
tree | 2e0b0f23f952a50c74d36f55934824768fdf71bf /packfile.c | |
parent | Merge branch 'en/submodule-merge-messages-fixes' (diff) | |
parent | is_promisor_object(): fix use-after-free of tree buffer (diff) | |
download | git-01a30a5a58053ce74a551a42d9edb2cf4f95632b.tar.xz git-01a30a5a58053ce74a551a42d9edb2cf4f95632b.zip |
Merge branch 'jk/is-promisor-object-keep-tree-in-use'
An earlier optimization discarded a tree-object buffer that is
still in use, which has been corrected.
* jk/is-promisor-object-keep-tree-in-use:
is_promisor_object(): fix use-after-free of tree buffer
Diffstat (limited to 'packfile.c')
-rw-r--r-- | packfile.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/packfile.c b/packfile.c index 5ae3ce8ea9..a41887c944 100644 --- a/packfile.c +++ b/packfile.c @@ -2217,7 +2217,17 @@ static int add_promisor_object(const struct object_id *oid, void *set_) { struct oidset *set = set_; - struct object *obj = parse_object(the_repository, oid); + struct object *obj; + int we_parsed_object; + + obj = lookup_object(the_repository, oid); + if (obj && obj->parsed) { + we_parsed_object = 0; + } else { + we_parsed_object = 1; + obj = parse_object(the_repository, oid); + } + if (!obj) return 1; @@ -2239,7 +2249,8 @@ static int add_promisor_object(const struct object_id *oid, return 0; while (tree_entry_gently(&desc, &entry)) oidset_insert(set, &entry.oid); - free_tree_buffer(tree); + if (we_parsed_object) + free_tree_buffer(tree); } else if (obj->type == OBJ_COMMIT) { struct commit *commit = (struct commit *) obj; struct commit_list *parents = commit->parents; |