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