diff options
author | IOhannes m zmölnig <zmoelnig@users.sourceforge.net> | 2005-05-11 14:06:27 +0000 |
---|---|---|
committer | IOhannes m zmölnig <zmoelnig@users.sourceforge.net> | 2005-05-11 14:06:27 +0000 |
commit | 6b7852c0eff01e7d224882aa5caf3a1677c13d20 (patch) | |
tree | 6e5cb2a2f1030898097abd769223bc797faf3922 | |
parent | c74f9041a42d95190b88990e91c2587f2f57a056 (diff) |
added safety checks whether the matrix is non-NULL
svn path=/trunk/externals/iem/iemmatrix/; revision=2948
-rw-r--r-- | src/mtx_mul.c | 5 | ||||
-rw-r--r-- | src/mtx_transpose.c | 4 |
2 files changed, 7 insertions, 2 deletions
diff --git a/src/mtx_mul.c b/src/mtx_mul.c index ef0f12b..8272d53 100644 --- a/src/mtx_mul.c +++ b/src/mtx_mul.c @@ -24,13 +24,16 @@ */ t_matrixfloat*mtx_doMultiply(int rowA, t_matrixfloat*A, int colArowB, t_matrixfloat*B, int colB){ - t_matrixfloat*result=(t_matrixfloat*)getbytes(sizeof(t_matrixfloat)*rowA*colB); + t_matrixfloat*result=0; + if(!A || !B || !rowA || !colArowB || !colB)return 0; + result=(t_matrixfloat*)getbytes(sizeof(t_matrixfloat)*rowA*colB); int r, c, n; for(r=0; r<rowA; r++){ for(c=0; c<colB; c++){ t_matrixfloat sum=0.f; for(n=0;n<colArowB; n++) sum+=A[colArowB*r+n]*B[colB*n+c]; + result[colB*r+c]=sum; } } return result; diff --git a/src/mtx_transpose.c b/src/mtx_transpose.c index 1fe2eab..ecc7722 100644 --- a/src/mtx_transpose.c +++ b/src/mtx_transpose.c @@ -18,7 +18,9 @@ static t_class *mtx_transpose_class; t_matrixfloat*mtx_doTranspose(t_matrixfloat*transposee, int row, int col){ int r,c; - t_matrixfloat*transposed=(t_matrixfloat*)getbytes(sizeof(t_matrixfloat)*row*col); + t_matrixfloat*transposed=0; + if(!transposee||!row||!col)return 0; + transposed=(t_matrixfloat*)getbytes(sizeof(t_matrixfloat)*row*col); r=row; while(r--){ c=col; |