Limit `ecall()` depth to 32 (default).

parent b00d45b0
......@@ -53,6 +53,11 @@ void abort(void);
#define MRB_FUNCALL_DEPTH_MAX 512
#endif
/* Maximum depth of ecall() recursion. */
#ifndef MRB_ECALL_DEPTH_MAX
#define MRB_ECALL_DEPTH_MAX 32
#endif
/* Maximum stack depth. Should be set lower on memory constrained systems.
The value below allows about 60000 recursive calls in the simplest case. */
#ifndef MRB_STACK_MAX
......@@ -319,7 +324,7 @@ ecall(mrb_state *mrb)
int nregs;
if (i<0) return;
if (ci - c->cibase > MRB_FUNCALL_DEPTH_MAX) {
if (ci - c->cibase > MRB_ECALL_DEPTH_MAX) {
mrb_exc_raise(mrb, mrb_obj_value(mrb->stack_err));
}
p = c->ensure[i];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment