From 568cc818cc26955eb0b94084d3068caabab1edd7 Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Mon, 6 Nov 2023 11:45:57 +0100 Subject: 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 Signed-off-by: Junio C Hamano --- shallow.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'shallow.c') diff --git a/shallow.c b/shallow.c index 5413719fd4..ac728cdd77 100644 --- a/shallow.c +++ b/shallow.c @@ -38,8 +38,10 @@ int register_shallow(struct repository *r, const struct object_id *oid) oidcpy(&graft->oid, oid); graft->nr_parent = -1; - if (commit && commit->object.parsed) + if (commit && commit->object.parsed) { + free_commit_list(commit->parents); commit->parents = NULL; + } return register_commit_graft(r, graft, 0); } -- cgit v1.3