Skip to content

Commit 31a57fa

Browse files
committed
Add repeat() memory boundary
1 parent d90488d commit 31a57fa

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

builtin/builtin.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,11 @@ var Functions = []*Function{
194194
{
195195
Name: "repeat",
196196
Func: func(args ...interface{}) (interface{}, error) {
197-
return strings.Repeat(args[0].(string), runtime.ToInt(args[1])), nil
197+
n := runtime.ToInt(args[1])
198+
if n > 1e6 {
199+
panic("memory budget exceeded")
200+
}
201+
return strings.Repeat(args[0].(string), n), nil
198202
},
199203
Types: types(strings.Repeat),
200204
},

0 commit comments

Comments
 (0)