ref: a34fdf2af87cc13b1d85cd19812c4d0b722f3e3a
parent: 9f34a074eb4f6a1ef4f27a85da65eb37f4149a87
author: Tor Andersson <tor.andersson@artifex.com>
date: Thu Mar 4 07:20:46 EST 2021
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.
--- a/jsrun.c
+++ b/jsrun.c
@@ -1038,9 +1038,12 @@
js_pop(J, n);
for (i = 0; i < F->varlen; ++i) {
- js_pushundefined(J);
- js_initvar(J, F->vartab[i], -1);
- js_pop(J, 1);
+ /* 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);