diff options
author | Binh-Minh Ribler <bmribler@hdfgroup.org> | 2019-05-05 05:41:19 (GMT) |
---|---|---|
committer | Binh-Minh Ribler <bmribler@hdfgroup.org> | 2019-05-05 05:41:19 (GMT) |
commit | bdf882ae392e56b7bf4c3e47ea26a0e19a0125f3 (patch) | |
tree | b37d28462ea4517db9bdb07f96e46375529e1229 /src/H5Dcompact.c | |
parent | 3bc708078c6da432e68d7c8cda695ad7b794c860 (diff) | |
download | hdf5-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/H5Dcompact.c')
-rw-r--r-- | src/H5Dcompact.c | 7 |
1 files changed, 6 insertions, 1 deletions
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, |