commit 4d0573ec49ba89483320bcbbbdf875ed936c16a6 from: Omar Polo via: Thomas Adam date: Fri Sep 02 15:54:01 2022 UTC gotwebd: always free ref in got_get_repo_commits some code-paths may leak it. ok stsp@ commit - acd4ff87e51fe0de84244536dfae7f503c4635ae commit + 4d0573ec49ba89483320bcbbbdf875ed936c16a6 blob - 55b30a337a5c628b4223bae7a3692a830ab1f1d2 blob + 079d6c4f0fa39bae6b6d665c9e4e75262b4ad0b8 --- gotwebd/got_operations.c +++ gotwebd/got_operations.c @@ -331,7 +331,7 @@ got_get_repo_commits(struct request *c, int limit) struct got_commit_graph *graph = NULL; struct got_commit_object *commit = NULL; struct got_reflist_head refs; - struct got_reference *ref; + struct got_reference *ref = NULL; struct repo_commit *repo_commit = NULL; struct server *srv = c->srv; struct transport *t = c->t; @@ -373,7 +373,6 @@ got_get_repo_commits(struct request *c, int limit) goto done; error = got_ref_resolve(&id, repo, ref); - got_ref_close(ref); if (error) goto done; } else if (qs->commit != NULL) { @@ -383,7 +382,6 @@ got_get_repo_commits(struct request *c, int limit) if (error) goto done; error = got_object_get_type(&obj_type, repo, id); - got_ref_close(ref); if (error) goto done; if (obj_type == GOT_OBJ_TYPE_TAG) { @@ -545,6 +543,8 @@ got_get_repo_commits(struct request *c, int limit) } done: gotweb_free_repo_commit(repo_commit); + if (ref) + got_ref_close(ref); if (commit) got_object_commit_close(commit); if (graph)