Skip to content

Commit 01a30a5

Browse files
committed
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
2 parents df3c129 + 1490d7d commit 01a30a5

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

packfile.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2217,7 +2217,17 @@ static int add_promisor_object(const struct object_id *oid,
22172217
void *set_)
22182218
{
22192219
struct oidset *set = set_;
2220-
struct object *obj = parse_object(the_repository, oid);
2220+
struct object *obj;
2221+
int we_parsed_object;
2222+
2223+
obj = lookup_object(the_repository, oid);
2224+
if (obj && obj->parsed) {
2225+
we_parsed_object = 0;
2226+
} else {
2227+
we_parsed_object = 1;
2228+
obj = parse_object(the_repository, oid);
2229+
}
2230+
22212231
if (!obj)
22222232
return 1;
22232233

@@ -2239,7 +2249,8 @@ static int add_promisor_object(const struct object_id *oid,
22392249
return 0;
22402250
while (tree_entry_gently(&desc, &entry))
22412251
oidset_insert(set, &entry.oid);
2242-
free_tree_buffer(tree);
2252+
if (we_parsed_object)
2253+
free_tree_buffer(tree);
22432254
} else if (obj->type == OBJ_COMMIT) {
22442255
struct commit *commit = (struct commit *) obj;
22452256
struct commit_list *parents = commit->parents;

t/t5616-partial-clone.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,13 @@ test_expect_success 'do partial clone 1' '
4949
test "$(git -C pc1 config --local remote.origin.partialclonefilter)" = "blob:none"
5050
'
5151

52+
test_expect_success 'rev-list --missing=allow-promisor on partial clone' '
53+
git -C pc1 rev-list --objects --missing=allow-promisor HEAD >actual &&
54+
git -C pc1 rev-list --objects --missing=print HEAD >expect.raw &&
55+
grep -v "^?" expect.raw >expect &&
56+
test_cmp expect actual
57+
'
58+
5259
test_expect_success 'verify that .promisor file contains refs fetched' '
5360
ls pc1/.git/objects/pack/pack-*.promisor >promisorlist &&
5461
test_line_count = 1 promisorlist &&

0 commit comments

Comments
 (0)