From d546fe2874ce8dc73cb0ac7541640fd202ec27c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Scharfe?= Date: Fri, 19 Jun 2020 15:13:46 +0200 Subject: commit-reach: plug minor memory leak after using is_descendant_of() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Acked-by: Derrick Stolee Signed-off-by: Junio C Hamano diff --git a/commit-reach.c b/commit-reach.c index 4ca7e70..6bba16e 100644 --- a/commit-reach.c +++ b/commit-reach.c @@ -396,6 +396,7 @@ int ref_newer(const struct object_id *new_oid, const struct object_id *old_oid) struct object *o; struct commit *old_commit, *new_commit; struct commit_list *old_commit_list = NULL; + int ret; /* * 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) return 0; commit_list_insert(old_commit, &old_commit_list); - return is_descendant_of(new_commit, old_commit_list); + ret = is_descendant_of(new_commit, old_commit_list); + free_commit_list(old_commit_list); + return ret; } /* -- cgit v0.10.2-6-g49f6