Skip to content

Commit

Permalink
Avoid writing of empty ir / data of sparse array
Browse files Browse the repository at this point in the history
  • Loading branch information
tbeu committed Jun 16, 2024
1 parent 9befe4c commit 39cfdfa
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/mat73.c
Original file line number Diff line number Diff line change
Expand Up @@ -2049,7 +2049,7 @@ Mat_VarWriteSparse73(hid_t id, matvar_t *matvar, const char *name)
H5Aclose(attr_id);
}

if ( MATIO_E_NO_ERROR == err ) {
if ( MATIO_E_NO_ERROR == err && sparse->ndata > 0 ) {
ndata = sparse->ndata;
h5_type = DataType2H5T(matvar->data_type);
h5_dtype = DataType(h5_type, matvar->isComplex);
Expand All @@ -2063,7 +2063,7 @@ Mat_VarWriteSparse73(hid_t id, matvar_t *matvar, const char *name)
H5Sclose(mspace_id);
}

if ( MATIO_E_NO_ERROR == err ) {
if ( MATIO_E_NO_ERROR == err && sparse->nir > 0 ) {
nir = sparse->nir;
mspace_id = H5Screate_simple(1, &nir, NULL);
dset_id = H5Dcreate(sparse_id, "ir", size_type_id, mspace_id, H5P_DEFAULT, H5P_DEFAULT,
Expand Down

0 comments on commit 39cfdfa

Please sign in to comment.