diff options
author | Binh-Minh Ribler <bmribler@hdfgroup.org> | 2019-06-03 18:16:02 (GMT) |
---|---|---|
committer | Binh-Minh Ribler <bmribler@hdfgroup.org> | 2019-06-03 18:16:02 (GMT) |
commit | c9ae1cf55730a0fe8a6d14f29213b3cdbc59503d (patch) | |
tree | fddc3499591b95c53b569462d86da81fefaf2778 /src | |
parent | 4af633d1c480deb7d27c1da7ee2c512a2500e543 (diff) | |
parent | 8a57a683391eed79aca80a7325ef152bb76ad0a6 (diff) | |
download | hdf5-c9ae1cf55730a0fe8a6d14f29213b3cdbc59503d.zip hdf5-c9ae1cf55730a0fe8a6d14f29213b3cdbc59503d.tar.gz hdf5-c9ae1cf55730a0fe8a6d14f29213b3cdbc59503d.tar.bz2 |
Merge pull request #1693 in HDFFV/hdf5 from ~BMRIBLER/hdf5-bmr:develop to develop
* commit '8a57a683391eed79aca80a7325ef152bb76ad0a6':
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')
-rw-r--r-- | src/H5Aint.c | 6 | ||||
-rw-r--r-- | src/H5Dchunk.c | 9 | ||||
-rw-r--r-- | src/H5Dcompact.c | 7 |
3 files changed, 17 insertions, 5 deletions
diff --git a/src/H5Aint.c b/src/H5Aint.c index d8ba92a..ebd6860 100644 --- a/src/H5Aint.c +++ b/src/H5Aint.c @@ -2396,9 +2396,13 @@ H5A__attr_post_copy_file(const H5O_loc_t *src_oloc, const H5A_t *attr_src, /* Check for expanding references */ if(cpy_info->expand_ref) { size_t ref_count; + size_t dst_dt_size; /* Destination datatype size */ + /* Determine size of the destination datatype */ + if(0 == (dst_dt_size = H5T_get_size(attr_dst->shared->dt))) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to determine datatype size") /* Determine # of reference elements to copy */ - ref_count = attr_dst->shared->data_size / H5T_get_size(attr_dst->shared->dt); + ref_count = attr_dst->shared->data_size / dst_dt_size; /* Copy objects referenced in source buffer to destination file and set destination elements */ if(H5O_copy_expand_ref(file_src, attr_dst->shared->data, file_dst, attr_dst->shared->data, ref_count, H5T_get_ref_type(attr_dst->shared->dt), cpy_info) < 0) diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c index 60f2d8b..a8dc398 100644 --- a/src/H5Dchunk.c +++ b/src/H5Dchunk.c @@ -707,15 +707,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]; diff --git a/src/H5Dcompact.c b/src/H5Dcompact.c index df61856..29401f8 100644 --- a/src/H5Dcompact.c +++ b/src/H5Dcompact.c @@ -559,9 +559,14 @@ H5D__compact_copy(H5F_t *f_src, H5O_storage_compact_t *_storage_src, H5F_t *f_ds /* Check for expanding references */ if(cpy_info->expand_ref) { size_t ref_count; + size_t src_dt_size; /* Source datatype size */ + + /* Determine largest datatype size */ + if(0 == (src_dt_size = H5T_get_size(dt_src))) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to determine datatype size") /* Determine # of reference elements to copy */ - ref_count = storage_src->size / H5T_get_size(dt_src); + ref_count = storage_src->size / src_dt_size; /* Copy objects referenced in source buffer to destination file and set destination elements */ if(H5O_copy_expand_ref(f_src, storage_src->buf, f_dst, |