about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog3
-rw-r--r--Src/loop.c2
-rw-r--r--Test/A01grammar.ztst8
3 files changed, 12 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index a65ba2970..fd58e7aa6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2016-06-21  Peter Stephenson  <p.stephenson@samsung.com>
 
+	* 38734: Src/loop.c, Test/A01grammar.ztst: fix final case
+	clauses terminating with ;&.
+
 	* 38692: Doc/Zsh/restricted.yo, Src/params.c: IFS can't be
 	changed in restricted mode.
 
diff --git a/Src/loop.c b/Src/loop.c
index 19d7f733e..fa7602e37 100644
--- a/Src/loop.c
+++ b/Src/loop.c
@@ -660,7 +660,7 @@ execcase(Estate state, int do_exec)
 	    execlist(state, 1, ((WC_CASE_TYPE(code) == WC_CASE_OR) &&
 				do_exec));
 	    while (!retflag && wc_code(code) == WC_CASE &&
-		   WC_CASE_TYPE(code) == WC_CASE_AND) {
+		   WC_CASE_TYPE(code) == WC_CASE_AND && state->pc < end) {
 		state->pc = next;
 		code = *state->pc++;
 		next = state->pc + WC_CASE_SKIP(code);
diff --git a/Test/A01grammar.ztst b/Test/A01grammar.ztst
index 7eedfa6e0..394480c19 100644
--- a/Test/A01grammar.ztst
+++ b/Test/A01grammar.ztst
@@ -283,6 +283,14 @@
 >2
 >3
 
+  case whatever in
+  (*) print yeah, right ;&
+  esac
+  print but well
+0:'case', redundant final ";&"
+>yeah, right
+>but well
+
 ## Select now reads from stdin if the shell is not interactive.
 ## Its own output goes to stderr.
   (COLUMNS=80 LINES=3