Bug 973563 - Correct assertion for zero-sized structs r=till

This commit is contained in:
Nicholas D. Matsakis 2014-02-24 14:31:15 -05:00
parent 3140adb1b5
commit ba30e5cf0d
2 changed files with 11 additions and 1 deletions

View File

@ -303,7 +303,8 @@ TypedObjectPointer.prototype.moveToFieldIndex = function(index) {
"bad field descr");
assert(TO_INT32(fieldOffset) === fieldOffset,
"bad field offset");
assert(fieldOffset >= 0 && fieldOffset < DESCR_SIZE(this.descr),
assert(fieldOffset >= 0 &&
(fieldOffset + DESCR_SIZE(fieldDescr)) <= DESCR_SIZE(this.descr),
"out of bounds field offset");
this.descr = fieldDescr;

View File

@ -0,0 +1,9 @@
// Test that empty sized structs don't trigger any assertion failures.
// Public domain.
if (!this.hasOwnProperty("TypedObject"))
quit();
var PointType = new TypedObject.StructType({});
var LineType = new TypedObject.StructType({source: PointType, target: PointType});
var fromAToB = new LineType({source: {x: 22, y: 44}, target: {x: 66, y: 88}});