Skip to content

Commit

Permalink
fix crash on multiplying too large number to a string
Browse files Browse the repository at this point in the history
  • Loading branch information
itchyny committed Aug 9, 2020
1 parent ea6aea5 commit 05129e3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion cli/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1792,7 +1792,7 @@
- name: multiply strings
args:
- '[-1.0, -0.5, 0.0, 0.5, 1.0, 1.5, 3.7, 10, 9444732965739290427392 / 4722366482869645213696, infinite][] * "abc"'
- '[-1.0, -0.5, 0.0, 0.5, 1.0, 1.5, 3.7, 10, 9444732965739290427392 / 4722366482869645213696, 1000000000, infinite][] * "abc"'
input: 'null'
expected: |
null
Expand All @@ -1805,6 +1805,7 @@
"abcabcabcabcabcabcabcabcabcabc"
"abcabc"
null
null
- name: multiply objects
args:
Expand Down
2 changes: 1 addition & 1 deletion operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ func funcOpMul(_, l, r interface{}) interface{} {
deepMergeObjects,
func(l, r interface{}) interface{} {
multiplyString := func(s string, cnt float64) interface{} {
if cnt <= 0.0 || int(cnt) < 0 {
if cnt <= 0.0 || int(cnt) < 0 || int(cnt) > maxHalfInt/(16*len(s)) {
return nil
}
if cnt < 1.0 {
Expand Down

0 comments on commit 05129e3

Please sign in to comment.