From b31ec5c564f02cf48d177853fd7bff9892be7ce6 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Wed, 22 Jun 2016 06:27:31 -0700 Subject: [PATCH] cmd/yacc: error rather than panic when TEMPSIZE is too small I tried simply increasing the size of the slice but then I got an error because NSTATES was too small. Leaving a real fix for after 1.7. Update #16144. Change-Id: I8676772cb79845dd4ca1619977d4d54a2ce6de59 Reviewed-on: https://go-review.googlesource.com/24321 Run-TryBot: Ian Lance Taylor TryBot-Result: Gobot Gobot Reviewed-by: Andrew Gerrand --- src/cmd/yacc/yacc.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/cmd/yacc/yacc.go b/src/cmd/yacc/yacc.go index 6f67ab6566..8a5df052ec 100644 --- a/src/cmd/yacc/yacc.go +++ b/src/cmd/yacc/yacc.go @@ -683,6 +683,10 @@ outer: levprd[nprod] = 0 } + if TEMPSIZE < ntokens+nnonter+1 { + errorf("too many tokens (%d) or non-terminals (%d)", ntokens, nnonter) + } + // // end of all rules // dump out the prefix code