From: Michael Tremer Date: Sun, 26 Jan 2025 15:22:02 +0000 (+0000) Subject: repo: Avoid double-free when downloading files X-Git-Tag: 0.9.30~371 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8ab031ffa6f82828f1c35cb486f1078566e05223;p=pakfire.git repo: Avoid double-free when downloading files We pass control over f to xfer which will close it, so we cannot call fclose() ourselves any more. Signed-off-by: Michael Tremer --- diff --git a/src/pakfire/repo.c b/src/pakfire/repo.c index 5403b6af..3a6b4b60 100644 --- a/src/pakfire/repo.c +++ b/src/pakfire/repo.c @@ -1270,7 +1270,7 @@ static int pakfire_repo_download(struct pakfire_repo* repo, const char* url, // Allocate a temporary file name f = pakfire_mktemp(path, 0); if (!f) { - r = 1; + r = -errno; goto ERROR; } @@ -1284,6 +1284,9 @@ static int pakfire_repo_download(struct pakfire_repo* repo, const char* url, if (r) goto ERROR; + // Reset f since its control has been passed to xfer + f = NULL; + // Run the download r = pakfire_xfer_run(xfer, 0); if (r)