s3: libsmbclient: Add readdirplus cleanup code on directory close.
authorPuran Chand <pchand@vmware.com>
Fri, 6 Apr 2018 21:17:35 +0000 (14:17 -0700)
committerJeremy Allison <jra@samba.org>
Fri, 4 May 2018 23:39:40 +0000 (01:39 +0200)
Signed-off-by: Puran Chand <pchand@vmware.com>
Reviewed-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Alexander Bokovoy <ab@samba.org>
source3/libsmb/libsmb_dir.c

index 8c3fed672f8a70b2bfa816592a80cd69e6046bed..828a28fe87d284fb0103a24a853874a0451cf1af 100644 (file)
  * 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);