1 |
commit: 58513b6cba580354031623c11049ab8e0a8e6970 |
2 |
Author: Mike Frysinger <vapier <AT> gentoo <DOT> org> |
3 |
AuthorDate: Thu Nov 26 09:48:28 2015 +0000 |
4 |
Commit: Mike Frysinger <vapier <AT> gentoo <DOT> org> |
5 |
CommitDate: Thu Nov 26 09:48:28 2015 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=58513b6c |
7 |
|
8 |
quse: fix invalid close |
9 |
|
10 |
This happens to work normally as we only have fds {0,1,2} open |
11 |
and {3} is the active file we're working on. Since the f loop |
12 |
contains 3 (for an unrelated reason), we close the right fd. |
13 |
But if there are more/fewer fd's open at start, it might fail, |
14 |
and we leak the FILE* structure. Switch to closing the right |
15 |
file pointer to avoid all this mess. |
16 |
|
17 |
quse.c | 2 +- |
18 |
1 file changed, 1 insertion(+), 1 deletion(-) |
19 |
|
20 |
diff --git a/quse.c b/quse.c |
21 |
index c7c1863..5ef88da 100644 |
22 |
--- a/quse.c |
23 |
+++ b/quse.c |
24 |
@@ -205,7 +205,7 @@ quse_describe_flag(unsigned int ind, unsigned int argc, char **argv) |
25 |
if (!strcmp(argv[i], buf)) |
26 |
printf(" %s%s%s:%s%s%s: %s\n", BOLD, de->d_name, NORM, BLUE, argv[i], NORM, p); |
27 |
} |
28 |
- close(f); |
29 |
+ fclose(fp[0]); |
30 |
} |
31 |
closedir(d); |