mirror of
https://github.com/hanzoai/expr.git
synced 2026-09-24 16:58:58 +00:00
Add repeat() memory boundary
This commit is contained in:
+5
-1
@@ -194,7 +194,11 @@ var Functions = []*Function{
|
||||
{
|
||||
Name: "repeat",
|
||||
Func: func(args ...interface{}) (interface{}, error) {
|
||||
return strings.Repeat(args[0].(string), runtime.ToInt(args[1])), nil
|
||||
n := runtime.ToInt(args[1])
|
||||
if n > 1e6 {
|
||||
panic("memory budget exceeded")
|
||||
}
|
||||
return strings.Repeat(args[0].(string), n), nil
|
||||
},
|
||||
Types: types(strings.Repeat),
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user