summaryrefslogtreecommitdiffstats
path: root/src/H5O.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2007-05-24 18:36:53 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2007-05-24 18:36:53 (GMT)
commitfa133cfb95c052f3b96b0a5089b98491b77628ef (patch)
treefb9226aa6db5511279a07f2486144ae3f2e88436 /src/H5O.c
parent415889bef3df70552a389214ca2ed241aa12e379 (diff)
downloadhdf5-fa133cfb95c052f3b96b0a5089b98491b77628ef.zip
hdf5-fa133cfb95c052f3b96b0a5089b98491b77628ef.tar.gz
hdf5-fa133cfb95c052f3b96b0a5089b98491b77628ef.tar.bz2
[svn-r13808] Description:
Fix possible file corruption when using "new" format object headers and the size of chunk #0 for an object header transitions between needing 1->2->4->8- byte encoding for the size and there are "clean" messages in the object header already. (Usually triggered by flushing the file while adding attributes to an object) Tested on: Mac OS X/32 10.4.9 (amazon) Linux/32 2.6 (chicago) Linux/64 2.6 (chicago2)
Diffstat (limited to 'src/H5O.c')
-rw-r--r--src/H5O.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/src/H5O.c b/src/H5O.c
index 0001529..9f66642 100644
--- a/src/H5O.c
+++ b/src/H5O.c
@@ -720,7 +720,7 @@ H5O_create(H5F_t *f, hid_t dxpl_id, size_t size_hint, hid_t ocpl_id,
/* Allocate disk space for header and first chunk */
if(HADDR_UNDEF == (oh_addr = H5MF_alloc(f, H5FD_MEM_OHDR, dxpl_id, (hsize_t)oh_size)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "file allocation failed for object header header")
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "file allocation failed for object header")
/* Create the chunk list */
oh->nchunks = oh->alloc_nchunks = 1;
@@ -1511,23 +1511,27 @@ static herr_t
H5O_obj_type_real(H5O_t *oh, H5O_type_t *obj_type)
{
const H5O_obj_class_t *obj_class; /* Class of object for header */
- herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT(H5O_obj_type_real)
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_obj_type_real)
/* Sanity check */
HDassert(oh);
HDassert(obj_type);
/* Look up class for object header */
- if(NULL == (obj_class = H5O_obj_class_real(oh)))
- HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to determine object type")
+ if(NULL == (obj_class = H5O_obj_class_real(oh))) {
+ /* Clear error stack from "failed" class lookup */
+ H5E_clear_stack(NULL);
- /* Set object type */
- *obj_type = obj_class->type;
+ /* Set type to "unknown" */
+ *obj_type = H5O_TYPE_UNKNOWN;
+ } /* end if */
+ else {
+ /* Set object type */
+ *obj_type = obj_class->type;
+ } /* end else */
-done:
- FUNC_LEAVE_NOAPI(ret_value)
+ FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5O_obj_type_real() */
@@ -1927,7 +1931,7 @@ H5O_get_info(H5O_loc_t *oloc, H5O_info_t *oinfo, hid_t dxpl_id)
/* Iterate over all the chunks, adding any gaps to the free space */
oinfo->hdr.space.total = 0;
for(u = 0, curr_chunk = &oh->chunk[0]; u < oh->nchunks; u++, curr_chunk++) {
- /* Accumulate the size of the header on header */
+ /* Accumulate the size of the header on disk */
oinfo->hdr.space.total += curr_chunk->size;
/* If the chunk has a gap, add it to the free space */