Limit ecall() depth to 32 (default).

This commit is contained in:
Yukihiro "Matz" Matsumoto
2017-12-06 14:30:12 +09:00
parent b00d45b095
commit ae44e80668
+6 -1
View File
@@ -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];