summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source3/smbd/dir.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/source3/smbd/dir.c b/source3/smbd/dir.c
index ab6e12f20f..04e3167e77 100644
--- a/source3/smbd/dir.c
+++ b/source3/smbd/dir.c
@@ -1139,16 +1139,6 @@ struct smb_Dir *OpenDir(connection_struct *conn, const char *name, const char *m
goto fail;
}
- if (dirp->name_cache_size) {
- dirp->name_cache = SMB_CALLOC_ARRAY(struct name_cache_entry,
- dirp->name_cache_size);
- if (!dirp->name_cache) {
- goto fail;
- }
- } else {
- dirp->name_cache = NULL;
- }
-
dirhandles_open++;
return dirp;
@@ -1295,10 +1285,19 @@ void DirCacheAdd(struct smb_Dir *dirp, const char *name, long offset)
{
struct name_cache_entry *e;
- if (!dirp->name_cache_size || !dirp->name_cache) {
+ if (dirp->name_cache_size == 0) {
return;
}
+ if (dirp->name_cache == NULL) {
+ dirp->name_cache = SMB_CALLOC_ARRAY(struct name_cache_entry,
+ dirp->name_cache_size);
+
+ if (dirp->name_cache == NULL) {
+ return;
+ }
+ }
+
dirp->name_cache_index = (dirp->name_cache_index+1) %
dirp->name_cache_size;
e = &dirp->name_cache[dirp->name_cache_index];