Skip to content

Commit ed5b53d

Browse files
committed
fix: 🐛 thrift2proto enum element endless loop
1 parent 64abb24 commit ed5b53d

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

thrift-2-proto-gen.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,13 @@ func (g *protoGenerator) handleEnum(e *thrifter.Enum) {
310310
continue
311311
}
312312

313+
// if g.currentToken is identical with ele.EndToken, means that the grammar is wrong
314+
if g.currentToken == ele.EndToken {
315+
logger.Errorf(fmt.Sprintf("invalid token for enum %s element %s, pass", e.Ident, g.currentToken.Raw))
316+
g.currentToken = g.currentToken.Next
317+
continue
318+
}
319+
313320
if !hasTraverseFirstElement {
314321
hasTraverseFirstElement = true
315322
// proto 3 enum first element must be zero, add a default element to it

0 commit comments

Comments
 (0)