fix env->stack misadjusting
@@ -141,7 +141,7 @@ stack_init(mrb_state *mrb)
}
static inline void
-envadjust(mrb_state *mrb, mrb_value *oldbase, mrb_value *newbase, size_t size)
+envadjust(mrb_state *mrb, mrb_value *oldbase, mrb_value *newbase, size_t oldsize)
{
mrb_callinfo *ci = mrb->c->cibase;
@@ -151,7 +151,7 @@ envadjust(mrb_state *mrb, mrb_value *oldbase, mrb_value *newbase, size_t size)
mrb_value *st;
if (e && MRB_ENV_STACK_SHARED_P(e) &&
- (st = e->stack) && oldbase <= st && st < oldbase+size) {
+ (st = e->stack) && oldbase <= st && st < oldbase+oldsize) {
ptrdiff_t off = e->stack - oldbase;
e->stack = newbase + off;
@@ -161,7 +161,7 @@ envadjust(mrb_state *mrb, mrb_value *oldbase, mrb_value *newbase, size_t size)
e = MRB_PROC_ENV(ci->proc);
if (e && MRB_ENV_STACK_SHARED_P(e) &&
- (st = e->stack) && oldbase <= st && st < oldbase+size) {
+ (st = e->stack) && oldbase <= st && st < oldbase+oldsize) {
ptrdiff_t off = e->stack - oldbase;
e->stack = newbase + off;
@@ -205,7 +205,7 @@ stack_extend_alloc(mrb_state *mrb, int room)
mrb_exc_raise(mrb, mrb_obj_value(mrb->stack_err));
}
stack_clear(&(newstack[oldsize]), size - oldsize);
- envadjust(mrb, oldbase, newstack, size);
+ envadjust(mrb, oldbase, newstack, oldsize);
mrb->c->stbase = newstack;
mrb->c->stack = mrb->c->stbase + off;
mrb->c->stend = mrb->c->stbase + size;
