From a6c30623d77b5fe759d5d9bedc33957ddaff1b4d Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Mon, 30 Sep 2024 11:14:21 +0200 Subject: remote: fix leaking push reports The push reports that report failures to the user when pushing a reference leak in several places. Plug these leaks by introducing a new function `ref_push_report_free()` that frees the list of reports and call it as required. While at it, fix a trivially leaking error string in the vicinity. These leaks get hit in t5411, but plugging them does not make the whole test suite pass. Signed-off-by: Patrick Steinhardt Signed-off-by: Junio C Hamano --- remote.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'remote.c') diff --git a/remote.c b/remote.c index e291e8ff5c..cd2091ac0c 100644 --- a/remote.c +++ b/remote.c @@ -868,6 +868,20 @@ struct strvec *push_url_of_remote(struct remote *remote) return remote->pushurl.nr ? &remote->pushurl : &remote->url; } +void ref_push_report_free(struct ref_push_report *report) +{ + while (report) { + struct ref_push_report *next = report->next; + + free(report->ref_name); + free(report->old_oid); + free(report->new_oid); + free(report); + + report = next; + } +} + static int match_name_with_pattern(const char *key, const char *name, const char *value, char **result) { @@ -1122,6 +1136,7 @@ void free_one_ref(struct ref *ref) if (!ref) return; free_one_ref(ref->peer_ref); + ref_push_report_free(ref->report); free(ref->remote_status); free(ref->tracking_ref); free(ref->symref); -- cgit v1.3