diff options
author | Stephen Gallagher <sgallagh@redhat.com> | 2010-06-17 15:55:42 -0400 |
---|---|---|
committer | Stephen Gallagher <sgallagh@redhat.com> | 2010-06-17 16:28:51 -0400 |
commit | 4c2cf0bc498c59343257fbae6dd93ec1a9fb88bc (patch) | |
tree | 570c5191f651bfe5fb677b66fa711a4ccf7a4c53 /src | |
parent | 6d65f4d78567cdcab9b0ab52e1f08ad054278cc7 (diff) | |
download | sssd_unused-4c2cf0bc498c59343257fbae6dd93ec1a9fb88bc.tar.gz sssd_unused-4c2cf0bc498c59343257fbae6dd93ec1a9fb88bc.tar.xz sssd_unused-4c2cf0bc498c59343257fbae6dd93ec1a9fb88bc.zip |
Fix potential resource leak in remove_tree_with_ctx()
https://fedorahosted.org/sssd/ticket/515
Diffstat (limited to 'src')
-rw-r--r-- | src/tools/files.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/tools/files.c b/src/tools/files.c index 3d45679d..69475354 100644 --- a/src/tools/files.c +++ b/src/tools/files.c @@ -110,7 +110,7 @@ static int remove_tree_with_ctx(TALLOC_CTX *mem_ctx, struct dirent direntp; struct stat statres; DIR *rootdir = NULL; - int ret; + int ret, err; rootdir = opendir(root); if (rootdir == NULL) { @@ -174,6 +174,7 @@ static int remove_tree_with_ctx(TALLOC_CTX *mem_ctx, } ret = closedir(rootdir); + rootdir = NULL; if (ret != 0) { ret = errno; goto fail; @@ -185,7 +186,15 @@ static int remove_tree_with_ctx(TALLOC_CTX *mem_ctx, goto fail; } + ret = EOK; + fail: + if (rootdir) { /* clean up on abnormal exit but retain return code */ + err = closedir(rootdir); + if (err) { + DEBUG(1, ("closedir failed, bad dirp?\n")); + } + } return ret; } |