Fix leaking lastIndex values in RegExp built-ins (#4166)
JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai daniel.batyai@h-lab.eu
This commit is contained in:
@@ -721,4 +721,33 @@ assert(r[Symbol.replace]("aaaa", function(match, index) {
|
||||
}) === "baaa");
|
||||
|
||||
assert (replaceCalled);
|
||||
assert (r.lastIndex === 2)
|
||||
assert (r.lastIndex === 2);
|
||||
|
||||
(function () {
|
||||
var r = /./g;
|
||||
var execWasCalled = false;
|
||||
var coercibleIndex = {
|
||||
valueOf: function() {
|
||||
return Math.pow(2, 54);
|
||||
},
|
||||
};
|
||||
|
||||
var result = {
|
||||
length: 1,
|
||||
0: '',
|
||||
index: 0,
|
||||
};
|
||||
|
||||
r.exec = function() {
|
||||
if (execWasCalled) {
|
||||
return null;
|
||||
}
|
||||
|
||||
r.lastIndex = coercibleIndex;
|
||||
execWasCalled = true;
|
||||
return result;
|
||||
};
|
||||
|
||||
assert(r[Symbol.replace]('', '') === '');
|
||||
assert(r.lastIndex === Math.pow(2, 53));
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user