Skip to content

Commit

Permalink
check for overflow
Browse files Browse the repository at this point in the history
Co-authored-by: Jordan Liggitt <jordan@liggitt.net>

Kubernetes-commit: 175bbaa8894a683cb7ba09f1e36160bc187840e4
  • Loading branch information
jpbetz authored and k8s-publishing-bot committed Aug 22, 2023
1 parent 6394fb8 commit 915c09d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions pkg/cel/library/cost.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,10 @@ func (l *CostEstimator) EstimateCallCost(function, overloadId string, target *ch
// find the longest replacement:
if toReplaceSz.Min == 0 {
// if the string being replaced is empty, replace surrounds all characters in the input string with the replacement.
if replaceCount.Max < math.MaxUint64 {
if sz.Max < math.MaxUint64 {
replaceCount.Max = sz.Max + 1
} else {
replaceCount.Max = sz.Max
}
// Include the length of the longest possible original string length.
retainedSz.Max = sz.Max
Expand All @@ -149,8 +151,10 @@ func (l *CostEstimator) EstimateCallCost(function, overloadId string, target *ch
// find the shortest replacement:
if toReplaceSz.Max == 0 {
// if the string being replaced is empty, replace surrounds all characters in the input string with the replacement.
if replaceCount.Min < math.MaxUint64 {
if sz.Min < math.MaxUint64 {
replaceCount.Min = sz.Min + 1
} else {
replaceCount.Min = sz.Min
}
// Include the length of the shortest possible original string length.
retainedSz.Min = sz.Min
Expand Down

0 comments on commit 915c09d

Please sign in to comment.