Bug 784015 - Fix division by 0 when calling ParallelArray.prototype.partition (r=dmandelin)

This commit is contained in:
Shu-yu Guo 2012-08-20 22:02:18 -07:00
parent f589c14e25
commit 5e7859bd23
2 changed files with 5 additions and 3 deletions

View File

@ -1366,7 +1366,7 @@ ParallelArrayObject::partition(JSContext *cx, CallArgs args)
// Throw if the outer dimension is not divisible by the new dimension.
uint32_t outer = obj->outermostDimension();
if (outer % newDimension) {
if (newDimension == 0 || outer % newDimension) {
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_PAR_ARRAY_BAD_PARTITION);
return false;
}

View File

@ -1,8 +1,10 @@
// |jit-test| error: Error;
load(libdir + "asserts.js");
function testPartitionDivisible() {
var p = new ParallelArray([1,2,3,4]);
var pp = p.partition(3);
var pp;
assertThrowsInstanceOf(function () { pp = p.partition(3); }, Error);
assertThrowsInstanceOf(function () { pp = p.partition(.34); }, Error);
}
testPartitionDivisible();