From 46309b39e9be7d49a6cdf416a427cc82e6ccab0f Mon Sep 17 00:00:00 2001 From: Anton Medvedev Date: Wed, 6 Sep 2023 09:51:46 +0200 Subject: [PATCH] Fix size check --- parser/lexer/utils.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/parser/lexer/utils.go b/parser/lexer/utils.go index 4e95a0093..5c9e6b59d 100644 --- a/parser/lexer/utils.go +++ b/parser/lexer/utils.go @@ -32,10 +32,11 @@ func unescape(value string) (string, error) { // The string contains escape characters. // The following logic is adapted from `strconv/quote.go` var runeTmp [utf8.UTFMax]byte - if n >= 2*math.MaxInt/3 { + size := 3 * uint64(n) / 2 + if size >= math.MaxInt { return "", fmt.Errorf("too large string") } - buf := make([]byte, 0, 3*n/2) + buf := make([]byte, 0, size) for len(value) > 0 { c, multibyte, rest, err := unescapeChar(value) if err != nil {