From: Puran Chand Date: Fri, 6 Apr 2018 21:17:35 +0000 (-0700) Subject: s3: libsmbclient: Add readdirplus cleanup code on directory close. X-Git-Tag: ldb-1.4.0~402 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3fc5a79750c443087ac0968085fadba74cce555d;p=thirdparty%2Fsamba.git s3: libsmbclient: Add readdirplus cleanup code on directory close. Signed-off-by: Puran Chand Reviewed-by: Jeremy Allison Reviewed-by: Andreas Schneider Reviewed-by: Alexander Bokovoy --- diff --git a/source3/libsmb/libsmb_dir.c b/source3/libsmb/libsmb_dir.c index 8c3fed672f8..828a28fe87d 100644 --- a/source3/libsmb/libsmb_dir.c +++ b/source3/libsmb/libsmb_dir.c @@ -40,6 +40,26 @@ * We accept the URL syntax explained in SMBC_parse_path(), above. */ +static void remove_dirplus(SMBCFILE *dir) +{ + struct smbc_dirplus_list *d = NULL; + + d = dir->dirplus_list; + while (d != NULL) { + struct smbc_dirplus_list *f = d; + d = d->next; + + SAFE_FREE(f->smb_finfo->short_name); + SAFE_FREE(f->smb_finfo->name); + SAFE_FREE(f->smb_finfo); + SAFE_FREE(f); + } + + dir->dirplus_list = NULL; + dir->dirplus_end = NULL; + dir->dirplus_next = NULL; +} + static void remove_dir(SMBCFILE *dir) { @@ -930,6 +950,7 @@ SMBC_closedir_ctx(SMBCCTX *context, } remove_dir(dir); /* Clean it up */ + remove_dirplus(dir); DLIST_REMOVE(context->internal->files, dir);