summaryrefslogtreecommitdiffstats
path: root/src/H5A.c
diff options
context:
space:
mode:
authorRaymond Lu <songyulu@hdfgroup.org>2009-06-26 19:41:32 (GMT)
committerRaymond Lu <songyulu@hdfgroup.org>2009-06-26 19:41:32 (GMT)
commitd8c0ebd42824f24ab457c1b98c90d0531f899103 (patch)
treee11a6f171dc2f4a893c5067d093434ee46ef3aef /src/H5A.c
parent084ab0cbde453e8f5847abbb06bc94cfe6f3e657 (diff)
downloadhdf5-d8c0ebd42824f24ab457c1b98c90d0531f899103.zip
hdf5-d8c0ebd42824f24ab457c1b98c90d0531f899103.tar.gz
hdf5-d8c0ebd42824f24ab457c1b98c90d0531f899103.tar.bz2
[svn-r17119] Bug fix #1513. Reading an empty attribute caused seg fault. The flag "initialized" in
the attribute structure wan't set correctly. It caused some confusion in H5A_read. This flag was actually redundant because the library can alwasy check if the data buffer is present. To fix it, I removed the "initialized" flag in the attribute structure and let H5A_read check the data buffer. Tested on jam, smirom, and linex.
Diffstat (limited to 'src/H5A.c')
-rw-r--r--src/H5A.c14
1 files changed, 1 insertions, 13 deletions
diff --git a/src/H5A.c b/src/H5A.c
index 325f7be..d359130 100644
--- a/src/H5A.c
+++ b/src/H5A.c
@@ -436,9 +436,6 @@ H5A_create(const H5G_loc_t *loc, const char *name, const H5T_t *type,
if(H5S_set_latest_version(attr->shared->ds) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set latest version of dataspace")
- /* Mark it initially set to initialized */
- attr->shared->initialized = TRUE; /*for now, set to false later*/
-
/* Copy the object header information */
if(H5O_loc_copy(&(attr->oloc), loc->oloc, H5_COPY_DEEP) < 0)
HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to copy entry")
@@ -498,9 +495,6 @@ H5A_create(const H5G_loc_t *loc, const char *name, const H5T_t *type,
if((ret_value = H5I_register(H5I_ATTR, attr, TRUE)) < 0)
HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register attribute for ID")
- /* Now it's safe to say it's uninitialized */
- attr->shared->initialized = FALSE;
-
done:
/* Cleanup on failure */
if(ret_value < 0 && attr && H5A_close(attr) < 0)
@@ -550,7 +544,6 @@ H5Aopen(hid_t loc_id, const char *attr_name, hid_t UNUSED aapl_id)
/* Read in attribute from object header */
if(NULL == (attr = H5O_attr_open_by_name(loc.oloc, attr_name, H5AC_ind_dxpl_id)))
HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to load attribute info from object header")
- attr->shared->initialized = TRUE;
/* Finish initializing attribute */
if(H5A_open_common(&loc, attr) < 0)
@@ -805,7 +798,6 @@ H5A_open_by_idx(const H5G_loc_t *loc, const char *obj_name, H5_index_t idx_type,
/* Read in attribute from object header */
if(NULL == (attr = H5O_attr_open_by_idx(obj_loc.oloc, idx_type, order, n, dxpl_id)))
HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, NULL, "unable to load attribute info from object header")
- attr->shared->initialized = TRUE;
/* Finish initializing attribute */
if(H5A_open_common(&obj_loc, attr) < 0)
@@ -871,7 +863,6 @@ H5A_open_by_name(const H5G_loc_t *loc, const char *obj_name, const char *attr_na
/* Read in attribute from object header */
if(NULL == (attr = H5O_attr_open_by_name(obj_loc.oloc, attr_name, dxpl_id)))
HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, NULL, "unable to load attribute info from object header")
- attr->shared->initialized = TRUE;
/* Finish initializing attribute */
if(H5A_open_common(loc, attr) < 0)
@@ -1036,9 +1027,6 @@ H5A_write(H5A_t *attr, const H5T_t *mem_type, const void *buf, hid_t dxpl_id)
HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to modify attribute")
} /* end if */
- /* Indicate the the attribute doesn't need fill-values */
- attr->shared->initialized = TRUE;
-
done:
/* Release resources */
if(src_id >= 0)
@@ -1144,7 +1132,7 @@ H5A_read(const H5A_t *attr, const H5T_t *mem_type, void *buf, hid_t dxpl_id)
dst_type_size = H5T_GET_SIZE(mem_type);
/* Check if the attribute has any data yet, if not, fill with zeroes */
- if(attr->obj_opened && !attr->shared->initialized)
+ if(attr->obj_opened && !attr->shared->data)
HDmemset(buf, 0, (dst_type_size * nelmts));
else { /* Attribute exists and has a value */
/* Convert memory buffer into disk buffer */