Close the file when fgets fails. Signed-off-by: Jan Safranek <jsafr...@redhat.com> ---
src/api.c | 10 +++++++++- 1 files changed, 9 insertions(+), 1 deletions(-) diff --git a/src/api.c b/src/api.c index 0acf787..5b2b518 100644 --- a/src/api.c +++ b/src/api.c @@ -3822,6 +3822,7 @@ int cgroup_get_all_controller_begin(void **handle, struct controller_data *info) { FILE *proc_cgroup = NULL; char buf[FILENAME_MAX]; + int ret; if (!info) return ECGINVAL; @@ -3834,11 +3835,18 @@ int cgroup_get_all_controller_begin(void **handle, struct controller_data *info) if (!fgets(buf, FILENAME_MAX, proc_cgroup)) { last_errno = errno; + fclose(proc_cgroup); + *handle = NULL; return ECGOTHER; } *handle = proc_cgroup; - return cgroup_get_all_controller_next(handle, info); + ret = cgroup_get_all_controller_next(handle, info); + if (ret != 0) { + fclose(proc_cgroup); + *handle = NULL; + } + return ret; } static int pid_compare(const void *a, const void *b) ------------------------------------------------------------------------------ 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