462fb2
There are missing calls of close() leading to resource leak (fd leak).
462fb2
Simple reproducer:
462fb2
. /
462fb2
and /proc/$$/fd contain one open fd for each above call
462fb2

462fb2
Signed-off-by: Roman Rakus <rrakus@redhat.com>
462fb2
---
462fb2
 builtins/evalfile.c | 3 +++
462fb2
 1 file changed, 3 insertions(+)
462fb2

462fb2
diff --git a/builtins/evalfile.c b/builtins/evalfile.c
462fb2
index 60f89d1..d30bd96 100644
462fb2
--- a/builtins/evalfile.c
462fb2
+++ b/builtins/evalfile.c
462fb2
@@ -133,11 +133,13 @@ file_error_and_exit:
462fb2
   if (S_ISDIR (finfo.st_mode))
462fb2
     {
462fb2
       (*errfunc) (_("%s: is a directory"), filename);
462fb2
+      close(fd);
462fb2
       return ((flags & FEVAL_BUILTIN) ? EXECUTION_FAILURE : -1);
462fb2
     }
462fb2
   else if ((flags & FEVAL_REGFILE) && S_ISREG (finfo.st_mode) == 0)
462fb2
     {
462fb2
       (*errfunc) (_("%s: not a regular file"), filename);
462fb2
+      close(fd);
462fb2
       return ((flags & FEVAL_BUILTIN) ? EXECUTION_FAILURE : -1);
462fb2
     }
462fb2
 
462fb2
@@ -146,6 +148,7 @@ file_error_and_exit:
462fb2
   if (file_size != finfo.st_size || file_size + 1 < file_size)
462fb2
     {
462fb2
       (*errfunc) (_("%s: file is too large"), filename);
462fb2
+      close(fd);
462fb2
       return ((flags & FEVAL_BUILTIN) ? EXECUTION_FAILURE : -1);
462fb2
     }      
462fb2
 
462fb2
-- 
462fb2
1.7.11.7
462fb2