]> rtime.felk.cvut.cz Git - fpga/lx-cpu1/binutils-tumbl.git/commitdiff
* objdump.c (slurp_file): Close file if fstat fails.
authorAlan Modra <amodra@bigpond.net.au>
Mon, 20 Feb 2012 03:25:20 +0000 (03:25 +0000)
committerAlan Modra <amodra@bigpond.net.au>
Mon, 20 Feb 2012 03:25:20 +0000 (03:25 +0000)
binutils/ChangeLog
binutils/objdump.c

index 577dd6f815d739bca923b775b6e3d8404d62feae..a6cc5547ba803fbdae85fca229190091f0ba2af9 100644 (file)
@@ -1,3 +1,7 @@
+2012-02-20  Namhyung Kim  <namhyung.kim@lge.com>
+
+       * objdump.c (slurp_file): Close file if fstat fails.
+
 2012-02-14  Cary Coutant  <ccoutant@google.com>
 
        * dwarf.c (dwarf_vmatoa64): New function.
index 76ca2db726e0beadd82c36e18a0ddfca0ae7cc26..f55b79d645415e466de4c3d7a6b8e4bde285329d 100644 (file)
@@ -1123,25 +1123,28 @@ 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);
   map = mmap (NULL, msize, PROT_READ, MAP_SHARED, fd, 0);
-  if (map != (char *)-1L)
+  if (map != (char *) -1L)
     {
-      close(fd);
-      return map; 
+      close (fd);
+      return map;
     }
 #endif
   map = (const char *) malloc (*size);
-  if (!map || (size_t) read (fd, (char *)map, *size) != *size) 
-    { 
-      free ((void *)map);
+  if (!map || (size_t) read (fd, (char *) map, *size) != *size)
+    {
+      free ((void *) map);
       map = NULL;
     }
   close (fd);
-  return map; 
+  return map;
 }
 
 #define line_map_decrease 5