diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/H5FDfamily.c | 14 | ||||
-rw-r--r-- | src/H5Gnode.c | 2 | ||||
-rw-r--r-- | src/H5Gstab.c | 4 | ||||
-rw-r--r-- | src/H5Tcommit.c | 2 |
4 files changed, 12 insertions, 10 deletions
diff --git a/src/H5FDfamily.c b/src/H5FDfamily.c index bd09ea4..5fd0294 100644 --- a/src/H5FDfamily.c +++ b/src/H5FDfamily.c @@ -628,7 +628,7 @@ H5FD_family_sb_encode(H5FD_t *_file, char *name/*out*/, unsigned char *buf/*out* FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FD_family_sb_encode) /* Name and version number */ - HDstrncpy(name, "NCSAfami", (size_t)8); + HDstrncpy(name, "NCSAfami", (size_t)9); name[8] = '\0'; /* Store member file size. Use the member file size from the property here. @@ -690,9 +690,9 @@ H5FD_family_sb_decode(H5FD_t *_file, const char UNUSED *name, const unsigned cha /* Check if member size from file access property is correct */ if(msize != file->pmem_size) { - char err_msg[128]; + char err_msg[128]; - sprintf(err_msg, "Family member size should be %lu. But the size from file access property is %lu", (unsigned long)msize, (unsigned long)file->pmem_size); + HDsnprintf(err_msg, sizeof(err_msg), "Family member size should be %lu. But the size from file access property is %lu", (unsigned long)msize, (unsigned long)file->pmem_size); HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, err_msg) } /* end if */ @@ -806,14 +806,14 @@ H5FD_family_open(const char *name, unsigned flags, hid_t fapl_id, file->flags = flags; /* Check that names are unique */ - sprintf(memb_name, name, 0); - sprintf(temp, name, 1); + HDsnprintf(memb_name, sizeof(memb_name), name, 0); + HDsnprintf(temp, sizeof(temp), name, 1); if(!HDstrcmp(memb_name, temp)) HGOTO_ERROR(H5E_FILE, H5E_FILEEXISTS, NULL, "file names not unique") /* Open all the family members */ while(1) { - sprintf(memb_name, name, file->nmembs); + HDsnprintf(memb_name, sizeof(memb_name), name, file->nmembs); /* Enlarge member array */ if(file->nmembs >= file->amembs) { @@ -1094,7 +1094,7 @@ H5FD_family_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t abs_eoa) /* Create another file if necessary */ if(u >= file->nmembs || !file->memb[u]) { file->nmembs = MAX(file->nmembs, u+1); - sprintf(memb_name, file->name, u); + HDsnprintf(memb_name, sizeof(memb_name), file->name, u); H5E_BEGIN_TRY { H5_CHECK_OVERFLOW(file->memb_size, hsize_t, haddr_t); file->memb[u] = H5FDopen(memb_name, file->flags | H5F_ACC_CREAT, diff --git a/src/H5Gnode.c b/src/H5Gnode.c index 5a2d736..5f32eb5 100644 --- a/src/H5Gnode.c +++ b/src/H5Gnode.c @@ -1239,7 +1239,7 @@ H5G_node_copy(H5F_t *f, hid_t dxpl_id, const void UNUSED *_lt_key, haddr_t addr, H5O_link_t lnk; /* Link to insert */ const char *name; /* Name of source object */ H5G_entry_t tmp_src_ent; /* Temperary copy. Change will not affect the cache */ - H5O_type_t obj_type; /* Target object type */ + H5O_type_t obj_type = H5O_TYPE_UNKNOWN; /* Target object type */ H5G_copy_file_ud_t *cpy_udata; /* Copy file udata */ H5G_obj_create_t gcrt_info; /* Group creation info */ diff --git a/src/H5Gstab.c b/src/H5Gstab.c index 7d0ad48..afa137c 100644 --- a/src/H5Gstab.c +++ b/src/H5Gstab.c @@ -711,6 +711,7 @@ H5G_stab_get_name_by_idx(H5O_loc_t *oloc, H5_iter_order_t order, hsize_t n, H5HL_t *heap = NULL; /* Pointer to local heap */ H5O_stab_t stab; /* Info about local heap & B-tree */ H5G_bt_it_gnbi_t udata; /* Iteration information */ + hbool_t udata_valid = FALSE; /* Whether iteration information is valid */ ssize_t ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5G_stab_get_name_by_idx, FAIL) @@ -744,6 +745,7 @@ H5G_stab_get_name_by_idx(H5O_loc_t *oloc, H5_iter_order_t order, hsize_t n, udata.common.op = H5G_stab_get_name_by_idx_cb; udata.heap = heap; udata.name = NULL; + udata_valid = TRUE; /* Iterate over the group members */ if(H5B_iterate(oloc->file, dxpl_id, H5B_SNODE, stab.btree_addr, H5G_node_by_idx, &udata) < 0) @@ -769,7 +771,7 @@ done: HDONE_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to unprotect symbol table heap") /* Free the duplicated name */ - if(udata.name != NULL) + if(udata_valid && udata.name != NULL) H5MM_xfree(udata.name); FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5Tcommit.c b/src/H5Tcommit.c index e109f95..d3779e5 100644 --- a/src/H5Tcommit.c +++ b/src/H5Tcommit.c @@ -221,7 +221,7 @@ done: /* If the datatype was committed but something failed after that, we need * to return it to the state it was in before it was committed. */ - if(ret_value < 0 && ocrt_info.new_obj) { + if(ret_value < 0 && (NULL != ocrt_info.new_obj)) { if(dt->shared->state == H5T_STATE_OPEN && dt->sh_loc.type == H5O_SHARE_TYPE_COMMITTED) { /* Remove the datatype from the list of opened objects in the file */ if(H5FO_top_decr(dt->sh_loc.file, dt->sh_loc.u.loc.oh_addr) < 0) |