Skip to content

Commit

Permalink
[MAT4] Add special case when nrows==0
Browse files Browse the repository at this point in the history
This fixes ticket:4581 by not crashing OMEdit when opening a corrupt
mat-file.

Belonging to [master]:
  - OpenModelica/OMCompiler#1937
  • Loading branch information
sjoelund authored and OpenModelica-Hudson committed Oct 24, 2017
1 parent a5b8a71 commit 2f828a2
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion SimulationRuntime/c/util/read_matlab4.c
Expand Up @@ -567,7 +567,9 @@ double* omc_matlab4_read_vals(ModelicaMatReader *reader, int varIndex)
size_t absVarIndex = abs(varIndex);
size_t ix = (varIndex < 0 ? absVarIndex + reader->nvar : absVarIndex) -1;
assert(absVarIndex > 0 && absVarIndex <= reader->nvar);
if(!reader->vars[ix]) {
if (0 == reader->nrows) {
return NULL;
} else if(!reader->vars[ix]) {
unsigned int i;
double *tmp = (double*) malloc(reader->nrows*sizeof(double));
if(reader->doublePrecision==1)
Expand Down

0 comments on commit 2f828a2

Please sign in to comment.