Skip to content

Commit

Permalink
fix crash on multiplying large numbers to an empty string (close #209)
Browse files Browse the repository at this point in the history
  • Loading branch information
itchyny committed Feb 19, 2023
1 parent 54b7644 commit 1a32db9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion cli/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2647,9 +2647,16 @@
- name: multiply empty string
args:
- '7 * ""'
- '(-9223372036854775808, -1, 0, 0.001, 0.999, 1, 7, 9223372036854775807) * ""'
input: 'null'
expected: |
null
null
null
""
""
""
""
""
- name: multiply objects
Expand Down
2 changes: 1 addition & 1 deletion operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ func repeatString(s string, n float64) any {
if n <= 0.0 || len(s) > 0 && n > float64(0x10000000/len(s)) || math.IsNaN(n) {
return nil
}
if n < 1.0 {
if int(n) < 1 {
return s
}
return strings.Repeat(s, int(n))
Expand Down

0 comments on commit 1a32db9

Please sign in to comment.