diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/H5Dchunk.c | 8 | ||||
-rw-r--r-- | src/H5Olayout.c | 7 |
2 files changed, 10 insertions, 5 deletions
diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c index 659d580..00a6b50 100644 --- a/src/H5Dchunk.c +++ b/src/H5Dchunk.c @@ -684,6 +684,7 @@ H5D__chunk_set_info_real(H5O_layout_chunk_t *layout, unsigned ndims, const hsize_t *curr_dims, const hsize_t *max_dims) { unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -695,10 +696,9 @@ 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 dimension must be positive: layout->dim[%u] = %u ", u, layout->dim[u]) - + /* Sanity check */ + HDassert(layout->dim[u] > 0); + /* 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]) diff --git a/src/H5Olayout.c b/src/H5Olayout.c index 5f16837..11d5d1c 100644 --- a/src/H5Olayout.c +++ b/src/H5Olayout.c @@ -243,9 +243,14 @@ H5O__layout_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, H5F_addr_decode(f, &p, &(mesg->storage.u.chunk.idx_addr)); /* Chunk dimensions */ - for(u = 0; u < mesg->u.chunk.ndims; u++) + for(u = 0; u < mesg->u.chunk.ndims; u++) { UINT32DECODE(p, mesg->u.chunk.dim[u]); + /* Just in case that something goes very wrong, such as file corruption. */ + if(mesg->u.chunk.dim[u] == 0) + HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, NULL, "chunk dimension must be positive: mesg->u.chunk.dim[%u] = %u", u, mesg->u.chunk.dim[u]) + } + /* Compute chunk size */ for(u = 1, mesg->u.chunk.size = mesg->u.chunk.dim[0]; u < mesg->u.chunk.ndims; u++) mesg->u.chunk.size *= mesg->u.chunk.dim[u]; |