Skip to content

Commit 568cc81

Browse files
pks-tgitster
authored andcommitted
shallow: fix memory leak when registering shallow roots
When registering shallow roots, we unset the list of parents of the to-be-registered commit if it's already been parsed. This causes us to leak memory though because we never free this list. Fix this. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 40e9136 commit 568cc81

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

shallow.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,10 @@ int register_shallow(struct repository *r, const struct object_id *oid)
3838

3939
oidcpy(&graft->oid, oid);
4040
graft->nr_parent = -1;
41-
if (commit && commit->object.parsed)
41+
if (commit && commit->object.parsed) {
42+
free_commit_list(commit->parents);
4243
commit->parents = NULL;
44+
}
4345
return register_commit_graft(r, graft, 0);
4446
}
4547

t/t5311-pack-bitmaps-shallow.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/bin/sh
22

33
test_description='check bitmap operation with shallow repositories'
4+
5+
TEST_PASSES_SANITIZE_LEAK=true
46
. ./test-lib.sh
57

68
# We want to create a situation where the shallow, grafted

t/t5530-upload-pack-error.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
test_description='errors in upload-pack'
44

5+
TEST_PASSES_SANITIZE_LEAK=true
56
. ./test-lib.sh
67

78
D=$(pwd)

0 commit comments

Comments
 (0)