This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] objdump: Close fd if fstat failed


2012-02-17  Namhyung Kim  <namhyung.kim@lge.com>

	* objdump.c (slurp_file): Close fd if fstat failed
---
 binutils/objdump.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/binutils/objdump.c b/binutils/objdump.c
index 76ca2db..fcbfb1a 100644
--- a/binutils/objdump.c
+++ b/binutils/objdump.c
@@ -1123,7 +1123,10 @@ slurp_file (const char *fn, size_t *size)
   if (fd < 0)
     return NULL;
   if (fstat (fd, &st) < 0)
-    return NULL;
+    {
+      close (fd);
+      return NULL;
+    }
   *size = st.st_size;
 #ifdef HAVE_MMAP
   msize = (*size + ps - 1) & ~(ps - 1);
-- 
1.7.9


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]