diff --git a/src/mat.c b/src/mat.c index b217e73a..69a9921f 100644 --- a/src/mat.c +++ b/src/mat.c @@ -2444,7 +2444,9 @@ Mat_VarPrint(const matvar_t *matvar, int printdata) const char *im = (const char *)complex_data->Im; for ( i = 0; i < (size_t)sparse->njc - 1; i++ ) { for ( j = sparse->jc[i]; - j < (size_t)sparse->jc[i + 1] && j < (size_t)sparse->ndata; j++ ) { + j < (size_t)sparse->jc[i + 1] && j < (size_t)sparse->ndata && + j < (size_t)sparse->nir; + j++ ) { printf(" (%u,%" SIZE_T_FMTSTR ") ", sparse->ir[j] + 1, i + 1); Mat_PrintNumber(matvar->data_type, re + j * stride); printf(" + ");