mirror of
https://github.com/ccxvii/mujs.git
synced 2026-02-05 17:29:43 +08:00
Bug 701886: Don't redefine/reset existing vars in script code.
If a var is already declared in the same scope, don't redeclare it. Should fix issues with "var" used in eval() code.
This commit is contained in:
3
jsrun.c
3
jsrun.c
@@ -1038,10 +1038,13 @@ static void jsR_callscript(js_State *J, int n, js_Function *F, js_Environment *s
|
||||
js_pop(J, n);
|
||||
|
||||
for (i = 0; i < F->varlen; ++i) {
|
||||
/* Bug 701886: don't redefine existing vars in eval/scripts */
|
||||
if (!js_hasvar(J, F->vartab[i])) {
|
||||
js_pushundefined(J);
|
||||
js_initvar(J, F->vartab[i], -1);
|
||||
js_pop(J, 1);
|
||||
}
|
||||
}
|
||||
|
||||
jsR_run(J, F);
|
||||
v = *stackidx(J, -1);
|
||||
|
||||
Reference in New Issue
Block a user