r2927: imported the hash2 name mangling code from Samba3 into Samba4, but
[jra/samba/.git] / source4 / ntvfs / posix / pvfs_dirlist.c
index 79d9a9a3fa9b2b234b4307849eea3915fa3d18f8..0482cda80871ede2a896894c526c542d6cfb909b 100644 (file)
@@ -98,21 +98,19 @@ NTSTATUS pvfs_list(struct pvfs_state *pvfs, struct pvfs_filename *name, struct p
        while ((dent = readdir(odir))) {
                uint_t i = dir->count;
                const char *dname = dent->d_name;
-               char *short_name;
 
-               short_name = pvfs_short_name_component(pvfs, dname);
-
-               /* check it matches the wildcard pattern */
                if (ms_fnmatch(pattern, dname, 
-                              pvfs->tcon->smb_conn->negotiate.protocol) != 0 &&
-                   ms_fnmatch(pattern, short_name, 
                               pvfs->tcon->smb_conn->negotiate.protocol) != 0) {
+                       char *short_name = pvfs_short_name_component(pvfs, dname);
+                       if (short_name == NULL ||
+                           ms_fnmatch(pattern, short_name, 
+                                      pvfs->tcon->smb_conn->negotiate.protocol) != 0) {
+                               talloc_free(short_name);
+                               continue;
+                       }
                        talloc_free(short_name);
-                       continue;
                }
 
-               talloc_free(short_name);
-               
                if (dir->count >= allocated) {
                        allocated = (allocated + 100) * 1.2;
                        dir->names = talloc_realloc_p(dir, dir->names, const char *, allocated);