Extend mruby stack when keep is bigger than room; fix #3421

But #3421 still cause stack overflow error due to infinite recursion.
To prevent overflow, we need to add different stack depth check.
This commit is contained in:
Yukihiro "Matz" Matsumoto
2017-02-14 00:15:58 +09:00
parent ecb6ac8b4a
commit 719f700adf
+3
View File
@@ -169,6 +169,9 @@ stack_extend_alloc(mrb_state *mrb, int room, int keep)
static inline void
stack_extend(mrb_state *mrb, int room, int keep)
{
if (room < keep) {
room = keep;
}
if (mrb->c->stack + room >= mrb->c->stend) {
stack_extend_alloc(mrb, room, keep);
}