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
1 changed files with 3 additions and 3 deletions

View File

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