]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/yacc: error rather than panic when TEMPSIZE is too small
authorIan Lance Taylor <iant@golang.org>
Wed, 22 Jun 2016 13:27:31 +0000 (06:27 -0700)
committerIan Lance Taylor <iant@golang.org>
Thu, 23 Jun 2016 04:29:35 +0000 (04:29 +0000)
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 <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Andrew Gerrand <adg@golang.org>
src/cmd/yacc/yacc.go

index 6f67ab65669cf6bf1fbc0f478a017f14bbf45d75..8a5df052ecf8a71e67360383c50425cefc18b9fe 100644 (file)
@@ -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