diff options
Diffstat (limited to 'source3')
-rw-r--r-- | source3/smbd/dir.c | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/source3/smbd/dir.c b/source3/smbd/dir.c index e6233166a0..7bca6bfd3d 100644 --- a/source3/smbd/dir.c +++ b/source3/smbd/dir.c @@ -1447,18 +1447,21 @@ bool is_visible_file(connection_struct *conn, const char *dir_path, static int smb_Dir_destructor(struct smb_Dir *dirp) { - if (dirp->dir) { -#ifdef HAVE_DIRFD - if (dirp->conn->sconn) { - files_struct *fsp = file_find_fd(dirp->conn->sconn, - dirfd(dirp->dir)); - if (fsp) { - /* The call below closes the underlying fd. */ - fsp->fh->fd = -1; + if (dirp->dir != NULL) { + SMB_VFS_CLOSEDIR(dirp->conn,dirp->dir); + if (dirp->fsp != NULL) { + /* + * The SMB_VFS_CLOSEDIR above + * closes the underlying fd inside + * dirp->fsp. + */ + dirp->fsp->fh->fd = -1; + if (dirp->fsp->dptr != NULL) { + SMB_ASSERT(dirp->fsp->dptr->dir_hnd == dirp); + dirp->fsp->dptr->dir_hnd = NULL; } + dirp->fsp = NULL; } -#endif - SMB_VFS_CLOSEDIR(dirp->conn,dirp->dir); } if (dirp->conn->sconn && !dirp->conn->sconn->using_smb2) { dirp->conn->sconn->searches.dirhandles_open--; |