diff options
-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 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]; 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, |