]> git.ipfire.org Git - thirdparty/git.git/commitdiff
commit-reach: plug minor memory leak after using is_descendant_of()
authorRené Scharfe <l.s.r@web.de>
Fri, 19 Jun 2020 13:13:46 +0000 (15:13 +0200)
committerJunio C Hamano <gitster@pobox.com>
Fri, 19 Jun 2020 18:06:01 +0000 (11:06 -0700)
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 <l.s.r@web.de>
Acked-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
commit-reach.c

index 4ca7e706a18ecf3c6cf862966b9d2f81d02bc964..6bba16e7b5f2c4372d8d088788d2501bca038830 100644 (file)
@@ -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;
 }
 
 /*