aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2008-07-20 23:03:23 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2008-07-20 23:03:23 +0000
commit7ae1cc16b4ecec930cd776f9ed688b6d4d53a166 (patch)
treedea5f9edc2fabb62c126930df82e7e1b4d443b73
parent2b68c8f74420c08ff3bb44d6745833ea715b6590 (diff)
downloadbusybox-w32-7ae1cc16b4ecec930cd776f9ed688b6d4d53a166.tar.gz
busybox-w32-7ae1cc16b4ecec930cd776f9ed688b6d4d53a166.tar.bz2
busybox-w32-7ae1cc16b4ecec930cd776f9ed688b6d4d53a166.zip
msh: fix "while...continue" bug 3884.
-rw-r--r--shell/msh.c8
-rw-r--r--shell/msh_test/msh-execution/many_continues.right1
-rwxr-xr-xshell/msh_test/msh-execution/many_continues.tests15
3 files changed, 24 insertions, 0 deletions
diff --git a/shell/msh.c b/shell/msh.c
index 44213c657..eb17eb668 100644
--- a/shell/msh.c
+++ b/shell/msh.c
@@ -2573,6 +2573,10 @@ static int execute(struct op *t, int *pin, int *pout, int no_fork)
2573 while (setjmp(bc.brkpt)) 2573 while (setjmp(bc.brkpt))
2574 if (isbreak) 2574 if (isbreak)
2575 goto broken; 2575 goto broken;
2576 /* Restore areanum value. It may be incremented by execute()
2577 * below, and then "continue" may jump back to setjmp above */
2578 areanum = a + 1;
2579 freearea(areanum + 1);
2576 brkset(&bc); 2580 brkset(&bc);
2577 for (t1 = t->left; i-- && *wp != NULL;) { 2581 for (t1 = t->left; i-- && *wp != NULL;) {
2578 setval(vp, *wp++); 2582 setval(vp, *wp++);
@@ -2586,6 +2590,10 @@ static int execute(struct op *t, int *pin, int *pout, int no_fork)
2586 while (setjmp(bc.brkpt)) 2590 while (setjmp(bc.brkpt))
2587 if (isbreak) 2591 if (isbreak)
2588 goto broken; 2592 goto broken;
2593 /* Restore areanum value. It may be incremented by execute()
2594 * below, and then "continue" may jump back to setjmp above */
2595 areanum = a + 1;
2596 freearea(areanum + 1);
2589 brkset(&bc); 2597 brkset(&bc);
2590 t1 = t->left; 2598 t1 = t->left;
2591 while ((execute(t1, pin, pout, /* no_fork: */ 0) == 0) == (t->op_type == TWHILE)) 2599 while ((execute(t1, pin, pout, /* no_fork: */ 0) == 0) == (t->op_type == TWHILE))
diff --git a/shell/msh_test/msh-execution/many_continues.right b/shell/msh_test/msh-execution/many_continues.right
new file mode 100644
index 000000000..d86bac9de
--- /dev/null
+++ b/shell/msh_test/msh-execution/many_continues.right
@@ -0,0 +1 @@
OK
diff --git a/shell/msh_test/msh-execution/many_continues.tests b/shell/msh_test/msh-execution/many_continues.tests
new file mode 100755
index 000000000..86c729abc
--- /dev/null
+++ b/shell/msh_test/msh-execution/many_continues.tests
@@ -0,0 +1,15 @@
1if test $# = 0; then
2 # Child will kill us in 1 second
3 "$THIS_SH" "$0" $$ &
4
5 # Loop many, many times
6 trap 'echo OK; exit 0' 15
7 while true; do
8 continue
9 done
10 echo BAD
11 exit 1
12fi
13
14sleep 1
15kill $1