]> Sergey Matveev's repositories - nnn.git/commitdiff
Read before write
authorArun Prakash Jana <engineerarun@gmail.com>
Tue, 29 Jan 2019 16:37:48 +0000 (22:07 +0530)
committerArun Prakash Jana <engineerarun@gmail.com>
Tue, 29 Jan 2019 16:37:48 +0000 (22:07 +0530)
src/nnn.c

index 2b8eafcbbed42de31ead3a89a53b109221b32f85..12fafa9ff5d79adb24a951a93ea6c50dd0d6ea47 100644 (file)
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -2519,9 +2519,10 @@ static int dentfill(char *path, struct entry **dents)
                /* Flag if this is a dir or symlink to a dir */
                if (S_ISDIR(sb.st_mode))
                        dentp->flags |= DIR_OR_LINK_TO_DIR;
-               else if (!S_ISLNK(sb.st_mode))
-                       dentp->flags &= ~DIR_OR_LINK_TO_DIR;
-               else {
+               else if (!S_ISLNK(sb.st_mode)) {
+                       if (dentp->flags & DIR_OR_LINK_TO_DIR)
+                               dentp->flags &= ~DIR_OR_LINK_TO_DIR;
+               } else {
                        if (!fstatat(fd, namep, &sb, 0)) {
                                if (S_ISDIR(sb.st_mode))
                                        dentp->flags |= DIR_OR_LINK_TO_DIR;