summaryrefslogtreecommitdiffstats
path: root/src
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
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')
-rw-r--r--src/H5A.c14
-rw-r--r--src/H5Aint.c3
-rw-r--r--src/H5Apkg.h1
-rw-r--r--src/H5Oattr.c6
4 files changed, 1 insertions, 23 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 */
diff --git a/src/H5Aint.c b/src/H5Aint.c
index 2ac17fa..475239a 100644
--- a/src/H5Aint.c
+++ b/src/H5Aint.c
@@ -1022,9 +1022,6 @@ H5A_attr_copy_file(const H5A_t *attr_src, H5F_t *file_dst, hbool_t *recompute_si
if(H5A_set_version(file_dst, attr_dst) < 0)
HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, NULL, "unable to update attribute version")
- /* Indicate that the fill values aren't to be written out */
- attr_dst->shared->initialized = TRUE;
-
/* Set return value */
ret_value = attr_dst;
diff --git a/src/H5Apkg.h b/src/H5Apkg.h
index 3c62635..4216fa3 100644
--- a/src/H5Apkg.h
+++ b/src/H5Apkg.h
@@ -75,7 +75,6 @@
/* Define the shared attribute structure */
typedef struct H5A_shared_t {
unsigned version; /* Version to encode attribute with */
- hbool_t initialized;/* Indicate whether the attribute has been modified */
char *name; /* Attribute's name */
H5T_cset_t encoding; /* Character encoding of attribute name */
diff --git a/src/H5Oattr.c b/src/H5Oattr.c
index 27b9d5e..1e85c69 100644
--- a/src/H5Oattr.c
+++ b/src/H5Oattr.c
@@ -226,9 +226,6 @@ H5O_attr_decode(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh, unsigned UNUSED mesg_fl
HDmemcpy(attr->shared->data, p, attr->shared->data_size);
} /* end if */
- /* Indicate that the fill values aren't to be written out */
- attr->shared->initialized = 1;
-
/* Increment the reference count for this object header message in cache(compact
storage) or for the object from dense storage. */
attr->shared->nrefs++;
@@ -805,9 +802,6 @@ H5O_attr_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg, FILE * stream, int in
"Character Set of Name:",
s);
HDfprintf(stream, "%*s%-*s %t\n", indent, "", fwidth,
- "Initialized:",
- mesg->shared->initialized);
- HDfprintf(stream, "%*s%-*s %t\n", indent, "", fwidth,
"Object opened:",
mesg->obj_opened);
HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth,