[bugfix] local variables should be initialized before copied to env object

This commit is contained in:
Yuichi Nishiwaki 2013-11-17 17:24:37 +09:00
parent 737f916a8c
commit 5668ae1b29
1 changed files with 10 additions and 9 deletions

View File

@ -525,6 +525,16 @@ pic_apply(pic_state *pic, struct pic_proc *proc, pic_value argv)
}
PUSH(rest);
}
/* prepare local variable area */
if (proc->u.irep->localc > 0) {
int l = proc->u.irep->localc;
if (proc->u.irep->varg) {
--l;
}
for (i = 0; i < l; ++i) {
PUSH(pic_undef_value());
}
}
/* prepare env */
if (proc->u.irep->cv_num == 0) {
@ -540,15 +550,6 @@ pic_apply(pic_state *pic, struct pic_proc *proc, pic_value argv)
}
}
/* prepare local variable area */
if (proc->u.irep->localc > 0) {
int l = proc->u.irep->localc;
if (proc->u.irep->varg) {
--l;
}
pic->sp += l;
}
pc = proc->u.irep->code;
pic_gc_arena_restore(pic, ai);
JUMP;