Use null matrix for invalid transport result

This commit is contained in:
Pascal Serrarens 2024-02-22 14:50:26 +01:00
parent a899a9dc44
commit c2e0a8afb2

View File

@ -28,9 +28,17 @@ public:
// but the data size should be equal to avoid problems
// We cannot check the data size directly, but the row*col should be equal
unsigned int matrixSize = this->cols * this->rows;
if (matrixSize != r->rows * r->cols)
// Exception??? For now we don't do anything
unsigned int resultSize = r->rows * r->cols;
if (matrixSize != resultSize) {
// Return a null matrix;
// We dont set data to nullptr because it is allocated memory
// Instead we write all zeros
for (int dataIx = 0; dataIx < resultSize; dataIx++)
r->data[dataIx] = 0.0f;
r->rows = 0;
r->cols = 0;
return;
}
r->cols = this->rows;
r->rows = this->cols;