From: Jan Mercl <0xjnml@gmail.com> Date: Thu, 18 Dec 2014 11:24:16 +0000 (+0100) Subject: cmd/yacc: Prevent index out of range. Fixes #9099. X-Git-Tag: go1.5beta1~2602 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=a034e478a7067db7ec0f3b549436bf6fbee3f4a0;p=gostls13.git cmd/yacc: Prevent index out of range. Fixes #9099. Change-Id: I7ef01a738b6ca49af1c148146d439c81b0a33b16 Reviewed-on: https://go-review.googlesource.com/1785 Reviewed-by: Ian Lance Taylor --- diff --git a/src/cmd/yacc/yacc.go b/src/cmd/yacc/yacc.go index 4dba376fc2..0a69c36afc 100644 --- a/src/cmd/yacc/yacc.go +++ b/src/cmd/yacc/yacc.go @@ -3400,6 +3400,13 @@ $$default: _ = $$pt // guard against "declared and not used" $$p -= $$R2[$$n] + // $$p is now the index of $0. Perform the default action. Iff the + // reduced production is ε, $1 is possibly out of range. + if $$p+1 >= len($$S) { + nyys := make([]$$SymType, len($$S)*2) + copy(nyys, $$S) + $$S = nyys + } $$VAL = $$S[$$p+1] /* consult goto table to find next state */