Skip to content

Commit

Permalink
Fix segmentation fault when reading compressed v5 MAT file with opaqu…
Browse files Browse the repository at this point in the history
…e class

* Skip unknown/undocumented opaque class
* As reported by #40
  • Loading branch information
tbeu committed Jul 11, 2016
1 parent 8e434f1 commit 3b6dc8f
Show file tree
Hide file tree
Showing 3 changed files with 210 additions and 197 deletions.
6 changes: 4 additions & 2 deletions src/mat.c
Original file line number Diff line number Diff line change
Expand Up @@ -1505,14 +1505,16 @@ Mat_VarGetSize(matvar_t *matvar)
matvar_t **fields = (matvar_t**)matvar->data;
if ( NULL != fields )
for ( i = 0; i < nmemb*nfields; i++ )
bytes += Mat_VarGetSize(fields[i]);
if ( NULL != fields[i] )
bytes += Mat_VarGetSize(fields[i]);
}
} else if ( matvar->class_type == MAT_C_CELL ) {
matvar_t **cells = (matvar_t**)matvar->data;
if ( NULL != cells ) {
int ncells = matvar->nbytes / matvar->data_size;
for ( i = 0; i < ncells; i++ )
bytes += Mat_VarGetSize(cells[i]);
if ( NULL != cells[i] )
bytes += Mat_VarGetSize(cells[i]);
}
} else {
int nmemb = 1;
Expand Down

0 comments on commit 3b6dc8f

Please sign in to comment.