Skip to content

Commit d546fe2

Browse files
rscharfegitster
authored andcommitted
commit-reach: plug minor memory leak after using is_descendant_of()
ref_newer() builds a commit_list to pass a single potential ancestor to is_descendant_of(). The latter leaves the list intact. Release the allocated memory after the call. Signed-off-by: René Scharfe <[email protected]> Acked-by: Derrick Stolee <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent af6b65d commit d546fe2

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

commit-reach.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,7 @@ int ref_newer(const struct object_id *new_oid, const struct object_id *old_oid)
396396
struct object *o;
397397
struct commit *old_commit, *new_commit;
398398
struct commit_list *old_commit_list = NULL;
399+
int ret;
399400

400401
/*
401402
* Both new_commit and old_commit must be commit-ish and new_commit is descendant of
@@ -417,7 +418,9 @@ int ref_newer(const struct object_id *new_oid, const struct object_id *old_oid)
417418
return 0;
418419

419420
commit_list_insert(old_commit, &old_commit_list);
420-
return is_descendant_of(new_commit, old_commit_list);
421+
ret = is_descendant_of(new_commit, old_commit_list);
422+
free_commit_list(old_commit_list);
423+
return ret;
421424
}
422425

423426
/*

0 commit comments

Comments
 (0)