summaryrefslogtreecommitdiffstats
path: root/src/H5Aint.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/H5Aint.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/H5Aint.c')
-rw-r--r--src/H5Aint.c6
1 files changed, 5 insertions, 1 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)