From a40b812b63e9f32c946761cb9cb7315ee57376ed Mon Sep 17 00:00:00 2001 From: Stephen Gallagher Date: Wed, 9 Jun 2010 09:59:52 -0400 Subject: Don't leak directory access resources on errors in directory_list() https://fedorahosted.org/sssd/ticket/514 --- common/path_utils/path_utils.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/common/path_utils/path_utils.c b/common/path_utils/path_utils.c index 493e0a4df..97c845c70 100644 --- a/common/path_utils/path_utils.c +++ b/common/path_utils/path_utils.c @@ -538,6 +538,10 @@ int directory_list(const char *path, bool recursive, error = path_concat(entry_path, sizeof(entry_path), path, entry->d_name); if (error != SUCCESS) { + closedir(dir); + /* Don't bother checking the return here. + * The path_concat error is more important + */ return error; } @@ -551,6 +555,10 @@ int directory_list(const char *path, bool recursive, error = directory_list(entry_path, recursive, callback, user_data); if (error != SUCCESS) { + closedir(dir); + /* Don't bother checking the return here. + * The directory_list error is more important + */ return error; } } -- cgit