summaryrefslogtreecommitdiffstats
path: root/tools/lib/h5tools.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/lib/h5tools.c')
-rw-r--r--tools/lib/h5tools.c33
1 files changed, 18 insertions, 15 deletions
diff --git a/tools/lib/h5tools.c b/tools/lib/h5tools.c
index 5031e44..344913a 100644
--- a/tools/lib/h5tools.c
+++ b/tools/lib/h5tools.c
@@ -1283,13 +1283,13 @@ init_acc_pos(h5tools_context_t *ctx, hsize_t *dims)
int i;
unsigned j;
- HDassert(ctx->ndims);
-
- ctx->acc[ctx->ndims - 1] = 1;
- for (i = ((int)ctx->ndims - 2); i >= 0; i--)
- ctx->acc[i] = ctx->acc[i + 1] * dims[i + 1];
- for (j = 0; j < ctx->ndims; j++)
- ctx->pos[j] = 0;
+ if(ctx->ndims > 0) {
+ ctx->acc[ctx->ndims - 1] = 1;
+ for (i = ((int)ctx->ndims - 2); i >= 0; i--)
+ ctx->acc[i] = ctx->acc[i + 1] * dims[i + 1];
+ for (j = 0; j < ctx->ndims; j++)
+ ctx->pos[j] = 0;
+ }
}
/*-------------------------------------------------------------------------
@@ -1410,13 +1410,17 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t
memb = H5Tget_super(tid);
ndims = H5Tget_array_ndims(tid);
H5Tget_array_dims2(tid, dims);
- HDassert(ndims >= 1 && ndims <= H5S_MAX_RANK);
-
- /* calculate the number of array elements */
- for (k = 0, nelmts = 1; k < ndims; k++) {
- temp_nelmts = nelmts;
- temp_nelmts *= dims[k];
- nelmts = (size_t) temp_nelmts;
+ if(ndims >= 1 && ndims <= H5S_MAX_RANK) {
+ /* calculate the number of array elements */
+ for (k = 0, nelmts = 1; k < ndims; k++) {
+ temp_nelmts = nelmts;
+ temp_nelmts *= dims[k];
+ nelmts = (size_t) temp_nelmts;
+ }
+ }
+ else {
+ H5Tclose(memb);
+ H5E_THROW(FAIL, H5E_tools_min_id_g, "calculate the number of array elements failed");
}
for (block_index = 0; block_index < block_nelmts; block_index++) {
@@ -1641,7 +1645,6 @@ render_bin_output_region_blocks(hid_t region_space, hid_t region_id,
ndims = (unsigned)sndims;
alloc_size = nblocks * ndims * 2 * sizeof(ptdata[0]);
- HDassert(alloc_size == (hsize_t) ((size_t) alloc_size)); /*check for overflow*/
if((ptdata = (hsize_t*) HDmalloc((size_t) alloc_size)) == NULL)
HGOTO_ERROR(FALSE, H5E_tools_min_id_g, "Could not allocate buffer for ptdata");