diff options
author | Jeremie Koenig <jk@jk.fr.eu.org> | 2010-08-25 14:31:56 +0200 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2010-08-26 23:48:34 +0200 |
commit | 862bdf3d26ac8fd61c7f7f6664bf0999774be434 (patch) | |
tree | 99906094f64673e84b153c2f7ae83d3c02c0fae0 /libps/ps.h | |
parent | 9ad43da4ff755b8e48e1b2f51271766061541dac (diff) | |
download | hurd-862bdf3d26ac8fd61c7f7f6664bf0999774be434.tar.gz hurd-862bdf3d26ac8fd61c7f7f6664bf0999774be434.tar.bz2 hurd-862bdf3d26ac8fd61c7f7f6664bf0999774be434.zip |
libps (_proc_stat_free): Fix memory leak
The thread_waits field was never freed; this change adds the code to do
so if the corresponding flag is set.
Users are also warned of the consequences, namely, that they should not
free process proc_stats before all their associated thread ones are
gone, since the latter may reference the former's thread_waits field.
However, with the normal interface (ie. ps_context_free), all
proc_stats are freed at once, so this is not an issue.
* libps/procstat.c (_proc_stat_free): Free ps->thread_waits if
PSTAT_THREAD_WAITS flag is set.
* libps/ps.h (_proc_stat_free): Document that thread proc_stats must be
freed before process proc_stat can be.
Diffstat (limited to 'libps/ps.h')
-rw-r--r-- | libps/ps.h | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -454,7 +454,9 @@ error_t _proc_stat_create (pid_t pid, struct ps_context *context, /* Frees PS and any memory/ports it references. Users shouldn't use this routine; proc_stats are normally freed only when their ps_context goes - away. */ + away. Insubordinate users will make sure they free the thread proc_stats + before they free the corresponding process proc_stat since the thread_wait + fields of the former may reference the latter. */ void _proc_stat_free (struct proc_stat *ps); /* Adds FLAGS to PS's flags, fetching information as necessary to validate |