mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
bug 531037 - eval fixes. r=brendan
This commit is contained in:
parent
0340e89b31
commit
a3f5d5c07b
@ -1442,7 +1442,7 @@ obj_eval(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
* calls to eval from global code are not cached.
|
||||
*/
|
||||
bucket = EvalCacheHash(cx, str);
|
||||
if (!indirectCall && caller->fun) {
|
||||
if (!indirectCall && argc == 1 && caller->fun) {
|
||||
uintN count = 0;
|
||||
JSScript **scriptp = bucket;
|
||||
|
||||
@ -1488,6 +1488,7 @@ obj_eval(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
}
|
||||
if (i < 0 ||
|
||||
STOBJ_GET_PARENT(objarray->vector[i]) == scopeobj) {
|
||||
JS_ASSERT(staticLevel == script->staticLevel);
|
||||
EVAL_CACHE_METER(hit);
|
||||
*scriptp = script->u.nextToGC;
|
||||
script->u.nextToGC = NULL;
|
||||
|
39
js/src/tests/js1_4/Eval/regress-531037.js
Normal file
39
js/src/tests/js1_4/Eval/regress-531037.js
Normal file
@ -0,0 +1,39 @@
|
||||
/* -*- Mode: java; tab-width:8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/licenses/publicdomain/
|
||||
*/
|
||||
|
||||
var gTestfile = 'regress-531037.js';
|
||||
//-----------------------------------------------------------------------------
|
||||
var BUGNUMBER = 531037;
|
||||
var summary = 'Checking corner cases of eval(source, scope) form';
|
||||
var actual;
|
||||
var expect = "No crash";
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
test();
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
function test() {
|
||||
enterFunc ('test');
|
||||
printBugNumber(BUGNUMBER);
|
||||
printStatus (summary);
|
||||
|
||||
var b = 10;
|
||||
var fff = function() { return --b >= 0; };
|
||||
var src = "while (fff());";
|
||||
eval(src, null);
|
||||
b = 10;
|
||||
try {
|
||||
eval(src, {fff: function() {throw 0;}});
|
||||
throw new Error("Unexpected success of eval");
|
||||
} catch (e) {
|
||||
if (e !== 0)
|
||||
throw e;
|
||||
}
|
||||
actual = "No crash";
|
||||
reportCompare(expect, actual, summary);
|
||||
exitFunc ('test');
|
||||
}
|
||||
|
22
js/src/trace-test/tests/basic/bug531037.js
Normal file
22
js/src/trace-test/tests/basic/bug531037.js
Normal file
@ -0,0 +1,22 @@
|
||||
/* -*- Mode: java; tab-width:8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/licenses/publicdomain/
|
||||
*/
|
||||
|
||||
(function() {
|
||||
var b = 10;
|
||||
var fff = function() { return --b >= 0; };
|
||||
var src = "while (fff());";
|
||||
eval(src, null);
|
||||
b = 10;
|
||||
try {
|
||||
eval(src, {fff: function() {throw 0;}});
|
||||
throw new Error("Unexpected success of eval");
|
||||
} catch (e) {
|
||||
if (e !== 0)
|
||||
throw e;
|
||||
}
|
||||
})();
|
||||
|
||||
// We expect this to finish without crashes or exceptions
|
Loading…
Reference in New Issue
Block a user