Fix leak in Array.prototype.indexOf() when 'fromIndex' can't coerce to primitive value.

JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai.u-szeged@partner.samsung.com
This commit is contained in:
Dániel Bátyai
2015-07-17 10:44:48 +02:00
committed by Evgeny Gavrin
parent 11c310322b
commit 27161d31df
2 changed files with 30 additions and 18 deletions
+17
View File
@@ -45,6 +45,23 @@ assert(obj.indexOf("foo") === -1);
var arr = [11, 22, 33, 44];
assert(arr.indexOf(44, 4) === -1);
var fromIndex = {
toString: function () {
return {};
},
valueOf: function () {
return {};
}
};
try {
[0, 1].indexOf(1, fromIndex);
assert(false);
} catch (e) {
assert(e instanceof TypeError);
}
// Checking behavior when unable to get length
var obj = { indexOf : Array.prototype.indexOf}
Object.defineProperty(obj, 'length', { 'get' : function () { throw new ReferenceError ("foo"); } });