Skip to content

Commit 46309b3

Browse files
committed
Fix size check
1 parent b05f809 commit 46309b3

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

parser/lexer/utils.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,11 @@ func unescape(value string) (string, error) {
3232
// The string contains escape characters.
3333
// The following logic is adapted from `strconv/quote.go`
3434
var runeTmp [utf8.UTFMax]byte
35-
if n >= 2*math.MaxInt/3 {
35+
size := 3 * uint64(n) / 2
36+
if size >= math.MaxInt {
3637
return "", fmt.Errorf("too large string")
3738
}
38-
buf := make([]byte, 0, 3*n/2)
39+
buf := make([]byte, 0, size)
3940
for len(value) > 0 {
4041
c, multibyte, rest, err := unescapeChar(value)
4142
if err != nil {

0 commit comments

Comments
 (0)