diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/H5B.c | 7 | ||||
-rw-r--r-- | src/H5Bcache.c | 8 |
2 files changed, 12 insertions, 3 deletions
@@ -228,7 +228,7 @@ H5B_create(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, void *udata, */ if (NULL==(bt = H5FL_MALLOC(H5B_t))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for B-tree root node") - HDmemset(&bt->cache_info,0,sizeof(H5AC2_info_t)); + HDmemset(&bt->cache_info, 0, sizeof(H5AC2_info_t)); bt->level = 0; bt->left = HADDR_UNDEF; bt->right = HADDR_UNDEF; @@ -1865,7 +1865,10 @@ H5B_copy(const H5B_t *old_bt) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for B-tree root node") /* Copy the main structure */ - HDmemcpy(new_node,old_bt,sizeof(H5B_t)); + HDmemcpy(new_node, old_bt, sizeof(H5B_t)); + + /* Reset cache info */ + HDmemset(&new_node->cache_info, 0, sizeof(H5AC2_info_t)); if ( NULL==(new_node->native=H5FL_BLK_MALLOC(native_block,shared->sizeof_keys)) || NULL==(new_node->child=H5FL_SEQ_MALLOC(haddr_t,(size_t)shared->two_k))) diff --git a/src/H5Bcache.c b/src/H5Bcache.c index 553876a..f18dee2 100644 --- a/src/H5Bcache.c +++ b/src/H5Bcache.c @@ -118,7 +118,7 @@ H5B_deserialize(haddr_t UNUSED addr, size_t UNUSED len, const void *image, const /* Allocate the B-tree node in memory */ if(NULL == (bt = H5FL_MALLOC(H5B_t))) HGOTO_ERROR(H5E_BTREE, H5E_NOSPACE, NULL, "can't allocate B-tree struct") - HDmemset(&bt->cache_info, 0, sizeof(bt->cache_info)); + HDmemset(&bt->cache_info, 0, sizeof(H5AC2_info_t)); /* Set & increment the ref-counted "shared" B-tree information for the node */ bt->rc_shared = udata->rc_shared; @@ -174,6 +174,9 @@ H5B_deserialize(haddr_t UNUSED addr, size_t UNUSED len, const void *image, const HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, NULL, "unable to decode key") } /* end if */ + /* Sanity check */ + HDassert((size_t)((const uint8_t *)p - (const uint8_t *)image) <= len); + /* Set return value */ ret_value = bt; @@ -261,6 +264,9 @@ H5B_serialize(haddr_t UNUSED addr, size_t UNUSED len, void *image, void *_thing, /* Reset the cache flags for this operation (metadata not resized or renamed) */ *flags = 0; + /* Sanity check */ + HDassert((size_t)((const uint8_t *)p - (const uint8_t *)image) <= len); + done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5B_serialize() */ |