[procfs] /proc/.../map file descriptor leak
authorJoel Brobecker <brobecker@gnat.com>
Thu, 10 Nov 2011 16:36:18 +0000 (16:36 +0000)
committerJoel Brobecker <brobecker@gnat.com>
Thu, 10 Nov 2011 16:36:18 +0000 (16:36 +0000)
When opening the procfs map file, we create a cleanup routine to make
sure that the associated file descriptor gets closed, but we never
call the cleanup. So the FD gets leaked.

gdb/ChangeLog:

        * procfs.c (iterate_over_mappings): Call do_cleanups before
        returning.

gdb/ChangeLog
gdb/procfs.c

index 4af934957bfba640c7be202eaebb61ed70ba42ad..24bf23f02cbca2aba8f02d029c7443af62135357 100644 (file)
@@ -1,3 +1,8 @@
+2011-11-10  Joel Brobecker  <brobecker@adacore.com>
+
+       * procfs.c (iterate_over_mappings): Call do_cleanups before
+       returning.
+
 2011-11-09  Doug Evans  <dje@google.com>
 
        * gdbtypes.c (check_typedef): Document that this function can
index 871dd47ab9d16018bfb84f9dd8f53f04b9c3e1d7..2a253a1bb08bb393e755585935141363cc63eb4e 100644 (file)
@@ -5217,6 +5217,7 @@ iterate_over_mappings (procinfo *pi, find_memory_region_ftype child_func,
   int funcstat;
   int map_fd;
   int nmap;
+  struct cleanup *cleanups = make_cleanup (null_cleanup, NULL);
 #ifdef NEW_PROC_API
   struct stat sbuf;
 #endif
@@ -5254,8 +5255,12 @@ iterate_over_mappings (procinfo *pi, find_memory_region_ftype child_func,
 
   for (prmap = prmaps; nmap > 0; prmap++, nmap--)
     if ((funcstat = (*func) (prmap, child_func, data)) != 0)
-      return funcstat;
+      {
+       do_cleanups (cleanups);
+        return funcstat;
+      }
 
+  do_cleanups (cleanups);
   return 0;
 }
 
This page took 0.036104 seconds and 4 git commands to generate.