You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This issue was found thanks to performing mutation analysis with Mutator (http://ortask.com/mutator/) on test suite matrix-test.js.
Calling function calcRotVec() of matrix.js on a matrix that is not 4x4 will crash the application with:
TypeError: Cannot call method 'set' of undefined
As suggested by mutation analysis, I added this test to matrix-test.js:
it('calculates the rotation vector for the matrix', function () {
var D = new Matrix(2,2);
D.set(0,0,0);
D.set(0,1,0);
D.set(1,0,0);
D.set(1,1,0);
var C = D.calcRotVec();
// oracle TBD
});
But it fails with the above TypeError due to the fact that calcRotVec() calls getRot(), and the creation of the inner/temp matrix in getRot() is bypassed when the caller matrix is not 4x4:
getRot: function () {
if (this.rows === 4 && this.cols === 4)
var C = new Matrix(3, 3); <--- Skipped when matrix is not 4x4
for (var r = 0; r < 3; ++r) {
for (var c = 0; c < 3; ++c) {
var val = this.get(r,c);
C.set(r,c, val); <--- TypeError here because C is truly undefined
}
}
return C;
},
The root-cause is that the getRot() function is missing curly braces to enclose the logic for the different sizes of matrices. However, even with braces, its implementation does not appear to suggest any paths for non-4x4 matrices.
The text was updated successfully, but these errors were encountered:
omgm
linked a pull request
Aug 29, 2014
that will
close
this issue
This issue was found thanks to performing mutation analysis with Mutator (http://ortask.com/mutator/) on test suite matrix-test.js.
Calling function calcRotVec() of matrix.js on a matrix that is not 4x4 will crash the application with:
As suggested by mutation analysis, I added this test to matrix-test.js:
But it fails with the above TypeError due to the fact that calcRotVec() calls getRot(), and the creation of the inner/temp matrix in getRot() is bypassed when the caller matrix is not 4x4:
The root-cause is that the getRot() function is missing curly braces to enclose the logic for the different sizes of matrices. However, even with braces, its implementation does not appear to suggest any paths for non-4x4 matrices.
The text was updated successfully, but these errors were encountered: