Skip to content

Commit

Permalink
Fix size check
Browse files Browse the repository at this point in the history
  • Loading branch information
antonmedv committed Sep 6, 2023
1 parent b05f809 commit 46309b3
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions parser/lexer/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 46309b3

Please sign in to comment.