diff options
-rw-r--r-- | src/H5Dchunk.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c index 22dc05a..fabae54 100644 --- a/src/H5Dchunk.c +++ b/src/H5Dchunk.c @@ -695,6 +695,10 @@ H5D__chunk_set_info_real(H5O_layout_chunk_t *layout, unsigned ndims, /* Compute the # of chunks in dataset dimensions */ for(u = 0, layout->nchunks = 1, layout->max_nchunks = 1; u < ndims; u++) { + /* Just in case that something goes very wrong, such as file corruption. */ + if(layout->dim[u] == 0) + HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "chunk size must be positive: layout->dim[%u] = %u ", u, layout->dim[u]) + /* Round up to the next integer # of chunks, to accommodate partial chunks */ layout->chunks[u] = ((curr_dims[u] + layout->dim[u]) - 1) / layout->dim[u]; if(H5S_UNLIMITED == max_dims[u]) |