Fixed panic on multipling string by very large number #2211

This commit is contained in:
Mike Farah
2024-12-07 16:53:40 +11:00
parent 2201381235
commit 342efb23ff
2 changed files with 10 additions and 0 deletions
+2
View File
@@ -155,6 +155,8 @@ func repeatString(lhs *CandidateNode, rhs *CandidateNode) (*CandidateNode, error
return nil, err
} else if count < 0 {
return nil, fmt.Errorf("Cannot repeat string by a negative number (%v)", count)
} else if count > 10000000 {
return nil, fmt.Errorf("Cannot repeat string by more than 100 million (%v)", count)
}
target.Value = strings.Repeat(stringNode.Value, count)