[git commit] hush: fix redirect code (was using uninitialized variables)

Denys Vlasenko vda.linux at googlemail.com
Fri Aug 11 13:41:39 UTC 2017


commit: https://git.busybox.net/busybox/commit/?id=d16e612c93d1a698c1a9d931b786cf3500996ae3
branch: https://git.busybox.net/busybox/commit/?id=refs/heads/master

Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
 shell/hush.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/shell/hush.c b/shell/hush.c
index dc05f24..1e58d71 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -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:


More information about the busybox-cvs mailing list