From: Arun Prakash Jana Date: Tue, 29 Jan 2019 16:37:48 +0000 (+0530) Subject: Read before write X-Git-Tag: v2.3~70 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=0ae1ef656c617e0b4c19180f989e082dc9d10783;p=nnn.git Read before write --- diff --git a/src/nnn.c b/src/nnn.c index 2b8eafcb..12fafa9f 100644 --- 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;