hush: fix redirect code (was using uninitialized variables)
authorDenys Vlasenko <vda.linux@googlemail.com>
Fri, 11 Aug 2017 13:41:39 +0000 (15:41 +0200)
committerDenys Vlasenko <vda.linux@googlemail.com>
Fri, 11 Aug 2017 13:41:39 +0000 (15:41 +0200)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
shell/hush.c

index dc05f24b9cd81f39780732aeb4b338f5b6f334f1..1e58d71e014ac69c582a95bdef971170d0b05b5c 100644 (file)
@@ -6741,7 +6741,8 @@ static struct squirrel *add_squirrel(struct squirrel *sq, int fd, int avoid_fd)
        int moved_to;
        int i;
 
-       if (sq) for (i = 0; sq[i].orig_fd >= 0; i++) {
+       i = 0;
+       if (sq) for (; sq[i].orig_fd >= 0; i++) {
                /* If we collide with an already moved fd... */
                if (fd == sq[i].moved_to) {
                        sq[i].moved_to = fcntl_F_DUPFD(sq[i].moved_to, avoid_fd);
@@ -6769,7 +6770,8 @@ static struct squirrel *add_squirrel_closed(struct squirrel *sq, int fd)
 {
        int i;
 
-       if (sq) for (i = 0; sq[i].orig_fd >= 0; i++) {
+       i = 0;
+       if (sq) for (; sq[i].orig_fd >= 0; i++) {
                /* If we collide with an already moved fd... */
                if (fd == sq[i].orig_fd) {
                        /* Examples: