1
0
mirror of https://github.com/golang/go synced 2024-11-18 21:05:02 -07:00

go/tools/go/gcimporter: avoid possible endless loops in case of errors

R=adonovan
CC=golang-dev
https://golang.org/cl/39630045
This commit is contained in:
Robert Griesemer 2013-12-09 15:43:31 -08:00
parent 7dcd8ded7c
commit d6902b2ad5

View File

@ -488,7 +488,7 @@ func (p *parser) parseStructType() types.Type {
p.expectKeyword("struct")
p.expect('{')
for i := 0; p.tok != '}'; i++ {
for i := 0; p.tok != '}' && p.tok != scanner.EOF; i++ {
if i > 0 {
p.expect(';')
}
@ -535,7 +535,7 @@ func (p *parser) parseParameter() (par *types.Var, isVariadic bool) {
//
func (p *parser) parseParameters() (list []*types.Var, isVariadic bool) {
p.expect('(')
for p.tok != ')' {
for p.tok != ')' && p.tok != scanner.EOF {
if len(list) > 0 {
p.expect(',')
}
@ -585,7 +585,7 @@ func (p *parser) parseInterfaceType() types.Type {
p.expectKeyword("interface")
p.expect('{')
for i := 0; p.tok != '}'; i++ {
for i := 0; p.tok != '}' && p.tok != scanner.EOF; i++ {
if i > 0 {
p.expect(';')
}