Bug 853576 - Check for negative indices supplied in scatter r=shu

This commit is contained in:
Nicholas D. Matsakis 2013-03-27 20:59:46 -04:00
parent 83edc3d65a
commit b13bb70f76
2 changed files with 9 additions and 1 deletions

View File

@ -953,7 +953,7 @@ function ParallelArrayScatter(targets, defaultValue, conflictFunc, length, mode)
if ((t | 0) !== t)
ThrowError(JSMSG_PAR_ARRAY_SCATTER_BAD_TARGET, i);
if (t >= length)
if (t < 0 || t >= length)
ThrowError(JSMSG_PAR_ARRAY_SCATTER_BOUNDS);
}
}

View File

@ -0,0 +1,8 @@
// |jit-test| error: Error;
var len = 2;
function add1(x) { return x+1; }
var p = new ParallelArray(len, add1);
var idx = [0,0].concat(build(len-4, add1)).concat([len-3,len-3]);
var revidx = idx.reverse();
var r = p.scatter(revidx, 0, function (x,y) { return x+y; }, len-2, {});