summaryrefslogtreecommitdiffstats
path: root/src/H5Dchunk.c
diff options
context:
space:
mode:
authorBinh-Minh Ribler <bmribler@hdfgroup.org>2019-05-05 05:41:19 (GMT)
committerBinh-Minh Ribler <bmribler@hdfgroup.org>2019-05-05 05:41:19 (GMT)
commitbdf882ae392e56b7bf4c3e47ea26a0e19a0125f3 (patch)
treeb37d28462ea4517db9bdb07f96e46375529e1229 /src/H5Dchunk.c
parent3bc708078c6da432e68d7c8cda695ad7b794c860 (diff)
downloadhdf5-bdf882ae392e56b7bf4c3e47ea26a0e19a0125f3.zip
hdf5-bdf882ae392e56b7bf4c3e47ea26a0e19a0125f3.tar.gz
hdf5-bdf882ae392e56b7bf4c3e47ea26a0e19a0125f3.tar.bz2
Code improvement
Description: Fixed potential division by zero occurrences and changed an assert to if statement. Platforms tested: Linux/64 (jelly) Linux/64 (platypus) Darwin (osx1011test)
Diffstat (limited to 'src/H5Dchunk.c')
-rw-r--r--src/H5Dchunk.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c
index 93b4427..0b38b0f 100644
--- a/src/H5Dchunk.c
+++ b/src/H5Dchunk.c
@@ -705,15 +705,18 @@ 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++) {
- /* 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])
layout->max_chunks[u] = H5S_UNLIMITED;
else
+ {
+ /* Sanity check */
+ if(layout->dim[u] == 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "dimension size must be > 0, dim = %u ", u)
+
layout->max_chunks[u] = ((max_dims[u] + layout->dim[u]) - 1) / layout->dim[u];
+ }
/* Accumulate the # of chunks */
layout->nchunks *= layout->chunks[u];