summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/H5Dchunk.c4
-rw-r--r--src/H5Doh.c2
-rw-r--r--src/H5Eint.c10
-rw-r--r--src/H5FDcore.c10
-rw-r--r--src/H5FDmpi.c19
-rw-r--r--src/H5HFsection.c12
-rw-r--r--src/H5HG.c2
-rw-r--r--src/H5MF.c4
-rw-r--r--src/H5Ocopy.c5
-rw-r--r--src/H5Otest.c2
-rw-r--r--src/H5Pfapl.c47
-rw-r--r--src/H5Shyper.c2
-rw-r--r--src/H5Spoint.c2
-rw-r--r--src/H5Sselect.c2
-rw-r--r--src/H5Tarray.c3
-rw-r--r--src/H5trace.c1
16 files changed, 82 insertions, 45 deletions
diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c
index 93e8869..7a06477 100644
--- a/src/H5Dchunk.c
+++ b/src/H5Dchunk.c
@@ -3798,7 +3798,9 @@ H5D__chunk_prune_by_extent(H5D_t *dset, hid_t dxpl_id, const hsize_t *old_dim)
/*
* Determine the chunks which need to be filled or removed
*/
- for(op_dim=0; op_dim<space_ndims; op_dim++) {
+ HDmemset(min_mod_chunk_off, 0, sizeof(min_mod_chunk_off));
+ HDmemset(max_mod_chunk_off, 0, sizeof(max_mod_chunk_off));
+ for(op_dim = 0; op_dim < space_ndims; op_dim++) {
/* Calculate the largest offset of chunks that might need to be
* modified in this dimension */
max_mod_chunk_off[op_dim] = chunk_dim[op_dim] * ((old_dim[op_dim] - 1)
diff --git a/src/H5Doh.c b/src/H5Doh.c
index 37b0f52..abf76d0 100644
--- a/src/H5Doh.c
+++ b/src/H5Doh.c
@@ -446,7 +446,7 @@ done:
static herr_t
H5O__dset_flush(H5G_loc_t *obj_loc, hid_t dxpl_id)
{
- H5D_t *dset; /* Dataset opened */
+ H5D_t *dset = NULL; /* Dataset opened */
H5O_type_t obj_type; /* Type of object at location */
herr_t ret_value = SUCCEED; /* Return value */
diff --git a/src/H5Eint.c b/src/H5Eint.c
index 594a69a..76eaaf5 100644
--- a/src/H5Eint.c
+++ b/src/H5Eint.c
@@ -264,7 +264,10 @@ H5E_walk1_cb(int n, H5E_error1_t *err_desc, void *client_data)
if(cls_ptr->lib_vers)
eprint->cls.lib_vers = cls_ptr->lib_vers;
- fprintf(stream, "%s-DIAG: Error detected in %s (%s) ", cls_ptr->cls_name, cls_ptr->lib_name, cls_ptr->lib_vers);
+ fprintf(stream, "%s-DIAG: Error detected in %s (%s) ",
+ (cls_ptr->cls_name ? cls_ptr->cls_name : "(null)"),
+ (cls_ptr->lib_name ? cls_ptr->lib_name : "(null)"),
+ (cls_ptr->lib_vers ? cls_ptr->lib_vers : "(null)"));
/* try show the process or thread id in multiple processes cases*/
#ifdef H5_HAVE_PARALLEL
@@ -387,7 +390,10 @@ H5E_walk2_cb(unsigned n, const H5E_error2_t *err_desc, void *client_data)
if(cls_ptr->lib_vers)
eprint->cls.lib_vers = cls_ptr->lib_vers;
- fprintf(stream, "%s-DIAG: Error detected in %s (%s) ", cls_ptr->cls_name, cls_ptr->lib_name, cls_ptr->lib_vers);
+ fprintf(stream, "%s-DIAG: Error detected in %s (%s) ",
+ (cls_ptr->cls_name ? cls_ptr->cls_name : "(null)"),
+ (cls_ptr->lib_name ? cls_ptr->lib_name : "(null)"),
+ (cls_ptr->lib_vers ? cls_ptr->lib_vers : "(null)"));
/* try show the process or thread id in multiple processes cases*/
#ifdef H5_HAVE_PARALLEL
diff --git a/src/H5FDcore.c b/src/H5FDcore.c
index 1fef36c..5b73866 100644
--- a/src/H5FDcore.c
+++ b/src/H5FDcore.c
@@ -427,8 +427,9 @@ H5FD_core_open(const char *name, unsigned flags, hid_t fapl_id,
HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, NULL, "maxaddr overflow")
HDassert(H5P_DEFAULT != fapl_id);
if(NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list")
- fa = (H5FD_core_fapl_t *)H5P_get_driver_info(plist);
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list")
+ if(NULL == (fa = (H5FD_core_fapl_t *)H5P_get_driver_info(plist)))
+ HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "bad VFL driver info")
/* Build the open flags */
o_flags = (H5F_ACC_RDWR & flags) ? O_RDWR : O_RDONLY;
@@ -443,6 +444,7 @@ H5FD_core_open(const char *name, unsigned flags, hid_t fapl_id,
/* If the file image exists and this is an open, make sure the file doesn't exist */
HDassert(((file_image_info.buffer != NULL) && (file_image_info.size > 0)) ||
((file_image_info.buffer == NULL) && (file_image_info.size == 0)));
+ HDmemset(&sb, 0, sizeof(sb));
if((file_image_info.buffer != NULL) && !(H5F_ACC_CREAT & flags)) {
if(HDopen(name, o_flags, 0666) >= 0)
HGOTO_ERROR(H5E_FILE, H5E_FILEEXISTS, NULL, "file already exists")
@@ -462,7 +464,7 @@ H5FD_core_open(const char *name, unsigned flags, hid_t fapl_id,
* store is off is when the backing_store flag is off and H5F_ACC_CREAT is
* on. */
else if(fa->backing_store || !(H5F_ACC_CREAT & flags)) {
- if(fa && (fd = HDopen(name, o_flags, 0666)) < 0)
+ if((fd = HDopen(name, o_flags, 0666)) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file")
if(HDfstat(fd, &sb) < 0)
HSYS_GOTO_ERROR(H5E_FILE, H5E_BADFILE, NULL, "unable to fstat file")
@@ -479,7 +481,7 @@ H5FD_core_open(const char *name, unsigned flags, hid_t fapl_id,
* default value. But if the file access property list was zero then use
* the default value instead.
*/
- file->increment = (fa && fa->increment>0) ? fa->increment : H5FD_CORE_INCREMENT;
+ file->increment = (fa->increment>0) ? fa->increment : H5FD_CORE_INCREMENT;
/* If save data in backing store. */
file->backing_store = fa->backing_store;
diff --git a/src/H5FDmpi.c b/src/H5FDmpi.c
index 01c28e6..866a2cf 100644
--- a/src/H5FDmpi.c
+++ b/src/H5FDmpi.c
@@ -56,12 +56,15 @@ char H5FD_mpi_native_g[] = "native";
int
H5FD_mpi_get_rank(const H5FD_t *file)
{
- const H5FD_class_mpi_t *cls=(const H5FD_class_mpi_t *)(file->cls);
+ const H5FD_class_mpi_t *cls;
+
int ret_value;
FUNC_ENTER_NOAPI(FAIL)
- assert(file && cls);
+ assert(file);
+ cls = (const H5FD_class_mpi_t *)(file->cls);
+ assert(cls);
assert(cls->get_rank); /* All MPI drivers must implement this */
/* Dispatch to driver */
@@ -92,12 +95,14 @@ done:
int
H5FD_mpi_get_size(const H5FD_t *file)
{
- const H5FD_class_mpi_t *cls=(const H5FD_class_mpi_t *)(file->cls);
+ const H5FD_class_mpi_t *cls;
int ret_value;
FUNC_ENTER_NOAPI(FAIL)
- assert(file && cls);
+ assert(file);
+ cls = (const H5FD_class_mpi_t *)(file->cls);
+ assert(cls);
assert(cls->get_size); /* All MPI drivers must implement this */
/* Dispatch to driver */
@@ -128,12 +133,14 @@ done:
MPI_Comm
H5FD_mpi_get_comm(const H5FD_t *file)
{
- const H5FD_class_mpi_t *cls=(const H5FD_class_mpi_t *)(file->cls);
+ const H5FD_class_mpi_t *cls;
MPI_Comm ret_value;
FUNC_ENTER_NOAPI(MPI_COMM_NULL)
- assert(file && cls);
+ assert(file);
+ cls = (const H5FD_class_mpi_t *)(file->cls);
+ assert(cls);
assert(cls->get_comm); /* All MPI drivers must implement this */
/* Dispatch to driver */
diff --git a/src/H5HFsection.c b/src/H5HFsection.c
index e9ea7e0..72ea100 100644
--- a/src/H5HFsection.c
+++ b/src/H5HFsection.c
@@ -2398,7 +2398,10 @@ H5HF_sect_indirect_init_rows(H5HF_hdr_t *hdr, hid_t dxpl_id,
HDassert(sect->u.indirect.span_size > 0);
/* Reset reference count for indirect section */
+ /* (Also reset the direct & indirect row pointers */
sect->u.indirect.rc = 0;
+ sect->u.indirect.dir_rows = NULL;
+ sect->u.indirect.indir_ents = NULL;
/* Set up direct block information, if necessary */
if(start_row < hdr->man_dtable.max_direct_rows) {
@@ -2424,7 +2427,6 @@ H5HF_sect_indirect_init_rows(H5HF_hdr_t *hdr, hid_t dxpl_id,
/* No rows of direct blocks covered, reset direct row information */
dir_nrows = 0;
sect->u.indirect.dir_nrows = 0;
- sect->u.indirect.dir_rows = NULL;
} /* end else */
/* Set up indirect block information, if necessary */
@@ -2459,7 +2461,6 @@ H5HF_sect_indirect_init_rows(H5HF_hdr_t *hdr, hid_t dxpl_id,
else {
/* No indirect block entries covered, reset indirect row information */
sect->u.indirect.indir_nents = 0;
- sect->u.indirect.indir_ents = NULL;
} /* end else */
/* Set up initial row information */
@@ -2598,6 +2599,13 @@ H5HF_sect_indirect_init_rows(H5HF_hdr_t *hdr, hid_t dxpl_id,
(sect->u.indirect.indir_nents + sect->u.indirect.dir_nrows));
done:
+ if(ret_value < 0) {
+ if(sect->u.indirect.indir_ents)
+ H5MM_xfree(sect->u.indirect.indir_ents);
+ if(sect->u.indirect.dir_rows)
+ H5MM_xfree(sect->u.indirect.dir_rows);
+ } /* end if */
+
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5HF_sect_indirect_init_rows() */
diff --git a/src/H5HG.c b/src/H5HG.c
index 0a97e47..7a90475 100644
--- a/src/H5HG.c
+++ b/src/H5HG.c
@@ -136,7 +136,7 @@ H5HG_create(H5F_t *f, hid_t dxpl_id, size_t size)
{
H5HG_heap_t *heap = NULL;
uint8_t *p = NULL;
- haddr_t addr;
+ haddr_t addr = HADDR_UNDEF;
size_t n;
haddr_t ret_value = HADDR_UNDEF; /* Return value */
diff --git a/src/H5MF.c b/src/H5MF.c
index 5b4505f..e708ab8 100644
--- a/src/H5MF.c
+++ b/src/H5MF.c
@@ -245,6 +245,7 @@ H5MF_alloc_open(H5F_t *f, hid_t dxpl_id, H5FD_mem_t type)
*/
HDassert(f);
HDassert(f->shared);
+ HDassert(type != H5FD_MEM_NOLIST);
HDassert(H5F_addr_defined(f->shared->fs_addr[type]));
HDassert(f->shared->fs_state[type] == H5F_FS_STATE_CLOSED);
@@ -292,6 +293,7 @@ H5MF_alloc_create(H5F_t *f, hid_t dxpl_id, H5FD_mem_t type)
*/
HDassert(f);
HDassert(f->shared);
+ HDassert(type != H5FD_MEM_NOLIST);
HDassert(!H5F_addr_defined(f->shared->fs_addr[type]));
HDassert(f->shared->fs_state[type] == H5F_FS_STATE_CLOSED);
@@ -342,6 +344,7 @@ H5MF_alloc_start(H5F_t *f, hid_t dxpl_id, H5FD_mem_t type)
*/
HDassert(f);
HDassert(f->shared);
+ HDassert(type != H5FD_MEM_NOLIST);
/* Check if the free space manager exists already */
if(H5F_addr_defined(f->shared->fs_addr[type])) {
@@ -384,6 +387,7 @@ H5MF_alloc_close(H5F_t *f, hid_t dxpl_id, H5FD_mem_t type)
*/
HDassert(f);
HDassert(f->shared);
+ HDassert(type != H5FD_MEM_NOLIST);
HDassert(f->shared->fs_man[type]);
HDassert(f->shared->fs_state[type] != H5F_FS_STATE_CLOSED);
diff --git a/src/H5Ocopy.c b/src/H5Ocopy.c
index 1d1aa90..ceb6563 100644
--- a/src/H5Ocopy.c
+++ b/src/H5Ocopy.c
@@ -1066,11 +1066,15 @@ H5O_copy_header(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out */,
FUNC_ENTER_NOAPI_NOINIT
+ /* Sanity check */
HDassert(oloc_src);
HDassert(oloc_src->file);
HDassert(H5F_addr_defined(oloc_src->addr));
HDassert(oloc_dst->file);
+ /* Intialize copy info before errors can be thrown */
+ HDmemset(&cpy_info, 0, sizeof(H5O_copy_t));
+
/* Get the copy property list */
if(NULL == (ocpy_plist = (H5P_genplist_t *)H5I_object(ocpypl_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list")
@@ -1088,7 +1092,6 @@ H5O_copy_header(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out */,
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get callback info")
/* Convert copy flags into copy struct */
- HDmemset(&cpy_info, 0, sizeof(H5O_copy_t));
if((cpy_option & H5O_COPY_SHALLOW_HIERARCHY_FLAG) > 0) {
cpy_info.copy_shallow = TRUE;
cpy_info.max_depth = 1;
diff --git a/src/H5Otest.c b/src/H5Otest.c
index 705f716..d1627ef 100644
--- a/src/H5Otest.c
+++ b/src/H5Otest.c
@@ -516,7 +516,7 @@ H5O_expunge_chunks_test(const H5O_loc_t *loc, hid_t dxpl_id)
/* Safety check */
nchunks = oh->nchunks;
- HDassert(nchunks < NELMTS(chk_addr));
+ HDassert(0 < nchunks && nchunks < NELMTS(chk_addr));
/* Iterate over all the chunks, saving the chunk addresses */
for(u = 0; u < oh->nchunks; u++)
diff --git a/src/H5Pfapl.c b/src/H5Pfapl.c
index f2af61b..9b5d1b0 100644
--- a/src/H5Pfapl.c
+++ b/src/H5Pfapl.c
@@ -2494,12 +2494,13 @@ done:
herr_t
H5P_file_image_info_copy(const char UNUSED *name, size_t UNUSED size, void *value)
{
- H5FD_file_image_info_t *info; /* Image info struct */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
if(value) {
+ H5FD_file_image_info_t *info; /* Image info struct */
+
info = (H5FD_file_image_info_t *)value;
/* verify file image field consistancy */
@@ -2533,16 +2534,17 @@ H5P_file_image_info_copy(const char UNUSED *name, size_t UNUSED size, void *valu
else
HDmemcpy(info->buffer, old_buffer, info->size);
} /* end if */
- } /* end if */
- /* Copy udata if it exists */
- if(info->callbacks.udata) {
- void *old_udata = info->callbacks.udata;
+ /* Copy udata if it exists */
+ if(info->callbacks.udata) {
+ void *old_udata = info->callbacks.udata;
+
+ if(NULL == info->callbacks.udata_copy)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "udata_copy not defined")
- if(NULL == info->callbacks.udata_copy)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "udata_copy not defined")
+ info->callbacks.udata = info->callbacks.udata_copy(old_udata);
+ } /* end if */
- info->callbacks.udata = info->callbacks.udata_copy(old_udata);
} /* end if */
done:
@@ -2567,32 +2569,33 @@ done:
herr_t
H5P_file_image_info_close(const char UNUSED *name, size_t UNUSED size, void *value)
{
- H5FD_file_image_info_t info; /* Image info struct */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
if(value) {
- info = *(H5FD_file_image_info_t *)value;
+ H5FD_file_image_info_t *info; /* Image info struct */
+
+ info = (H5FD_file_image_info_t *)value;
- if(info.buffer != NULL && info.size > 0) {
+ if(info->buffer != NULL && info->size > 0) {
/* Free buffer */
- if(info.callbacks.image_free) {
- if(info.callbacks.image_free(info.buffer, H5FD_FILE_IMAGE_OP_PROPERTY_LIST_CLOSE,
- info.callbacks.udata) < 0)
+ if(info->callbacks.image_free) {
+ if(info->callbacks.image_free(info->buffer, H5FD_FILE_IMAGE_OP_PROPERTY_LIST_CLOSE,
+ info->callbacks.udata) < 0)
HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "image_free callback failed")
} /* end if */
else
- H5MM_xfree(info.buffer);
+ H5MM_xfree(info->buffer);
} /* end if */
- } /* end if */
- /* Free udata if it exists */
- if(info.callbacks.udata) {
- if(NULL == info.callbacks.udata_free)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "udata_free not defined")
- if(info.callbacks.udata_free(info.callbacks.udata) < 0)
- HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "udata_free callback failed")
+ /* Free udata if it exists */
+ if(info->callbacks.udata) {
+ if(NULL == info->callbacks.udata_free)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "udata_free not defined")
+ if(info->callbacks.udata_free(info->callbacks.udata) < 0)
+ HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "udata_free callback failed")
+ } /* end if */
} /* end if */
done:
diff --git a/src/H5Shyper.c b/src/H5Shyper.c
index d9b306d..d88ac35 100644
--- a/src/H5Shyper.c
+++ b/src/H5Shyper.c
@@ -2784,7 +2784,7 @@ H5S_hyper_offset(const H5S_t *space, hsize_t *offset)
FUNC_ENTER_NOAPI(FAIL)
- HDassert(space);
+ HDassert(space && space->extent.rank>0);
HDassert(offset);
/* Start at linear offset 0 */
diff --git a/src/H5Spoint.c b/src/H5Spoint.c
index 817b2f2..b758a92 100644
--- a/src/H5Spoint.c
+++ b/src/H5Spoint.c
@@ -643,7 +643,7 @@ H5S_point_copy(H5S_t *dst, const H5S_t *src, hbool_t UNUSED share_selection)
} /* end while */
done:
- if(ret_value < 0) {
+ if(ret_value < 0 && dst->select.sel_info.pnt_lst) {
/* Traverse the (incomplete?) dst list, freeing all memory */
curr = dst->select.sel_info.pnt_lst->head;
while(curr) {
diff --git a/src/H5Sselect.c b/src/H5Sselect.c
index 91aed1e..9a993a5 100644
--- a/src/H5Sselect.c
+++ b/src/H5Sselect.c
@@ -67,7 +67,7 @@ H5S_select_offset(H5S_t *space, const hssize_t *offset)
/* Check args */
HDassert(space);
- HDassert(space->extent.rank);
+ HDassert(0 < space->extent.rank && space->extent.rank <= H5S_MAX_RANK);
HDassert(offset);
/* Copy the offset over */
diff --git a/src/H5Tarray.c b/src/H5Tarray.c
index 9986631..c73b934 100644
--- a/src/H5Tarray.c
+++ b/src/H5Tarray.c
@@ -194,7 +194,8 @@ H5T__array_create(H5T_t *base, unsigned ndims, const hsize_t dim[/* ndims */])
ret_value->shared->type = H5T_ARRAY;
/* Copy the base type of the array */
- ret_value->shared->parent = H5T_copy(base, H5T_COPY_ALL);
+ if(NULL == (ret_value->shared->parent = H5T_copy(base, H5T_COPY_ALL)))
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, NULL, "unable to copy base datatype")
/* Set the array parameters */
ret_value->shared->u.array.ndims = ndims;
diff --git a/src/H5trace.c b/src/H5trace.c
index b711f40..b559669 100644
--- a/src/H5trace.c
+++ b/src/H5trace.c
@@ -212,6 +212,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...)
if('[' == *type) {
if('a' == type[1]) {
asize_idx = (int)HDstrtol(type + 2, &rest, 10);
+ HDassert(0 <= asize_idx && asize_idx < (int) NELMTS(asize));
HDassert(']'==*rest);
type = rest + 1;
} else {