diff options
author | Joel Brobecker <brobecker@gnat.com> | 2011-11-10 16:36:18 +0000 |
---|---|---|
committer | Joel Brobecker <brobecker@gnat.com> | 2011-11-10 16:36:18 +0000 |
commit | 0a86f36427b729c3b7dfa5a9142848db9877ddc0 (patch) | |
tree | f8db270640cc485aa265cdb6a6c2a7172e29f129 /gdb | |
parent | 9bc118a5d44548773b26f6a7f186f14009f00786 (diff) | |
download | gdb-0a86f36427b729c3b7dfa5a9142848db9877ddc0.zip gdb-0a86f36427b729c3b7dfa5a9142848db9877ddc0.tar.gz gdb-0a86f36427b729c3b7dfa5a9142848db9877ddc0.tar.bz2 |
[procfs] /proc/.../map file descriptor leak
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.
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/ChangeLog | 5 | ||||
-rw-r--r-- | gdb/procfs.c | 7 |
2 files changed, 11 insertions, 1 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 4af9349..24bf23f 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -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 diff --git a/gdb/procfs.c b/gdb/procfs.c index 871dd47..2a253a1 100644 --- a/gdb/procfs.c +++ b/gdb/procfs.c @@ -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; } |