This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[PATCH] objdump: Close fd if fstat failed
- From: Namhyung Kim <namhyung dot kim at lge dot com>
- To: binutils at sourceware dot org
- Date: Fri, 17 Feb 2012 17:45:38 +0900
- Subject: [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