]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
Early close for mapped files in libdwfl.
authorRoland McGrath <roland@redhat.com>
Mon, 21 Jun 2010 11:41:03 +0000 (04:41 -0700)
committerRoland McGrath <roland@redhat.com>
Mon, 21 Jun 2010 11:41:03 +0000 (04:41 -0700)
libdwfl/ChangeLog
libdwfl/open.c

index 92be9488a9007fa494dbac8ec5f1becee24013c3..e71e33d67f60723203104debcfd2aa869d8da4d1 100644 (file)
@@ -1,5 +1,7 @@
 2010-06-21  Roland McGrath  <roland@redhat.com>
 
+       * open.c (__libdw_open_file): Close the fd when it's already mapped.
+
        * dwfl_module_getsrc_file.: Update for Dwarf_Line member change.
        * dwfl_lineinfo.c: Likewise.  Use dwarf_lineaddr.
 
index 397af358f8b14f275cf39e44da5f94108e9df6dd..063dece84243bd16385af365131c9d0975cb4c00 100644 (file)
@@ -190,9 +190,13 @@ __libdw_open_file (int *fdp, Elf **elfp, bool close_on_fail, bool archive_ok)
     {
       elf_end (elf);
       elf = NULL;
+      close_fd = close_on_fail;
     }
 
-  if (error == DWFL_E_NOERROR ? close_fd : close_on_fail)
+  if (*fdp != -1
+      && (close_fd || (close_on_fail
+                      && elf->map_address != NULL
+                      && elf_cntl (elf, ELF_C_FDREAD) == 0)))
     {
       close (*fdp);
       *fdp = -1;