cgroup_walk_tree_begin() can end up with error and in some code paths '*handle' is not set and in some it is.
The functiomn should free all resources on error + return *handle = NULL Signed-off-by: Jan Safranek <jsafr...@redhat.com> --- src/api.c | 15 +++++++++++---- 1 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/api.c b/src/api.c index 2ed9e22..e0ed696 100644 --- a/src/api.c +++ b/src/api.c @@ -3078,8 +3078,6 @@ int cgroup_walk_tree_begin(const char *controller, const char *base_path, cgroup_dbg("path is %s\n", base_path); - cgroup_dbg("path is %s\n", base_path); - if (!cg_build_path(base_path, full_path, controller)) return ECGOTHER; @@ -3087,6 +3085,7 @@ int cgroup_walk_tree_begin(const char *controller, const char *base_path, if (!entry) { last_errno = errno; + *handle = NULL; return ECGOTHER; } @@ -3101,20 +3100,28 @@ int cgroup_walk_tree_begin(const char *controller, const char *base_path, if (entry->fts == NULL) { free(entry); last_errno = errno; + *handle = NULL; return ECGOTHER; } ent = fts_read(entry->fts); if (!ent) { cgroup_dbg("fts_read failed\n"); + fts_close(entry->fts); free(entry); + *handle = NULL; return ECGINVAL; } if (!*base_level && depth) *base_level = ent->fts_level + depth; ret = cg_walk_node(entry->fts, ent, *base_level, info, entry->flags); - - *handle = entry; + if (ret != 0) { + fts_close(entry->fts); + free(entry); + *handle = NULL; + } else { + *handle = entry; + } return ret; } ------------------------------------------------------------------------------ Get a FREE DOWNLOAD! and learn more about uberSVN rich system, user administration capabilities and model configuration. Take the hassle out of deploying and managing Subversion and the tools developers use with it. http://p.sf.net/sfu/wandisco-dev2dev _______________________________________________ Libcg-devel mailing list Libcg-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/libcg-devel