From d1a34dd8a2a8e577e78e2ccd1ef59813751755ef Mon Sep 17 00:00:00 2001 From: Stefan Sperling Date: Sat, 28 Dec 2024 13:26:40 +0000 Subject: [PATCH] plug imsgbuf-related memory leaks in got_fetch_pack() --- lib/fetch.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/fetch.c b/lib/fetch.c index 15808325..1f3365fb 100644 --- a/lib/fetch.c +++ b/lib/fetch.c @@ -131,6 +131,8 @@ got_fetch_pack(struct got_object_id **pack_hash, struct got_pathlist_head *refs, char *progress = NULL; *pack_hash = NULL; + memset(&fetchibuf, 0, sizeof(fetchibuf)); + memset(&idxibuf, 0, sizeof(idxibuf)); if (repo && got_repo_get_object_format(repo) != GOT_HASH_SHA1) return got_error_fmt(GOT_ERR_NOT_IMPL, @@ -543,6 +545,10 @@ got_fetch_pack(struct got_object_id **pack_hash, struct got_pathlist_head *refs, tmpidxpath = NULL; done: + if (fetchibuf.w) + imsgbuf_clear(&fetchibuf); + if (idxibuf.w) + imsgbuf_clear(&idxibuf); if (tmppackpath && unlink(tmppackpath) == -1 && err == NULL) err = got_error_from_errno2("unlink", tmppackpath); if (tmpidxpath && unlink(tmpidxpath) == -1 && err == NULL) -- 2.11.4.GIT