aboutsummaryrefslogtreecommitdiffstats
path: root/core/apk-tools/fd-leak.patch
blob: 5f6a55ff80db0dd1db1c1a7b94fada4b95788034 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
commit bd6278fb28d1d87a58a591244fe1069aa4216a6f
Author: Natanael Copa <ncopa@alpinelinux.org>
Date:   Tue May 26 14:12:02 2009 +0000

    fetch: fix fd leak
    
    we should always close the in-stream, not only on failure.

diff --git a/src/fetch.c b/src/fetch.c
index 9e0d930..f3c651b 100644
--- a/src/fetch.c
+++ b/src/fetch.c
@@ -95,10 +95,10 @@ static int fetch_package(struct fetch_ctx *fctx,
 	}
 
 	r = apk_istream_splice(is, fd, pkg->size, NULL, NULL);
+	is->close(is);
 	if (fd != STDOUT_FILENO)
 		close(fd);
 	if (r != pkg->size) {
-		is->close(is);
 		apk_error("Unable to download '%s'", file);
 		unlink(file);
 		return -1;