Skip to content

Commit 2683a94

Browse files
committed
Add check for int64->int conversion
1 parent 1894b2a commit 2683a94

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

parser/parser.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package parser
22

33
import (
44
"fmt"
5+
"math"
56
"strconv"
67
"strings"
78

@@ -310,6 +311,10 @@ func (p *parser) parseSecondary() Node {
310311
if err != nil {
311312
p.error("invalid hex literal: %v", err)
312313
}
314+
if number > math.MaxInt {
315+
p.error("integer literal is too large")
316+
return nil
317+
}
313318
node := &IntegerNode{Value: int(number)}
314319
node.SetLocation(token.Location)
315320
return node
@@ -326,6 +331,10 @@ func (p *parser) parseSecondary() Node {
326331
if err != nil {
327332
p.error("invalid integer literal: %v", err)
328333
}
334+
if number > math.MaxInt {
335+
p.error("integer literal is too large")
336+
return nil
337+
}
329338
node := &IntegerNode{Value: int(number)}
330339
node.SetLocation(token.Location)
331340
return node

0 commit comments

Comments
 (0)