summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--release_docs/RELEASE.txt2
-rw-r--r--src/H5Oattr.c5
-rw-r--r--test/tattr.c67
3 files changed, 73 insertions, 1 deletions
diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt
index 2c29bb8..1e1518e 100644
--- a/release_docs/RELEASE.txt
+++ b/release_docs/RELEASE.txt
@@ -186,6 +186,8 @@ Bug Fixes since HDF5-1.6.0 release
Library
-------
+ - Fix segmentation fault when calling H5Fflush with an attribute that
+ hasn't had a value written to it open. QAK - 2004/10/18
- Back up supporting bitfield and time types in H5Tget_native_type.
Leave it to future support. The function simply returns error
message of "not support" for bitfield and time types.
diff --git a/src/H5Oattr.c b/src/H5Oattr.c
index f816b2c..1493403 100644
--- a/src/H5Oattr.c
+++ b/src/H5Oattr.c
@@ -340,7 +340,10 @@ H5O_attr_encode(H5F_t *f, uint8_t *p, const void *mesg)
p += attr->ds_size;
/* Store attribute data */
- HDmemcpy(p,attr->data,attr->data_size);
+ if(attr->data)
+ HDmemcpy(p,attr->data,attr->data_size);
+ else
+ HDmemset(p,0,attr->data_size);
done:
FUNC_LEAVE_NOAPI(ret_value);
diff --git a/test/tattr.c b/test/tattr.c
index ded9a79..6727442 100644
--- a/test/tattr.c
+++ b/test/tattr.c
@@ -395,6 +395,72 @@ test_attr_basic_read(void)
/****************************************************************
**
+** test_attr_flush(): Test H5A (attribute) code for performing
+** I/O when H5Fflush is used.
+**
+****************************************************************/
+static void
+test_attr_flush(void)
+{
+ hid_t fil, /* File ID */
+ att, /* Attribute ID */
+ spc, /* Dataspace ID */
+ set; /* Dataset ID */
+ double wdata=3.14159; /* Data to write */
+ double rdata; /* Data read in */
+ herr_t ret; /* Generic return value */
+
+ /* Output message about test being performed */
+ MESSAGE(5, ("Testing Attribute Flushing\n"));
+
+ fil = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(fil, FAIL, "H5Fcreate");
+
+ spc = H5Screate(H5S_SCALAR);
+ CHECK(spc, FAIL, "H5Screate");
+
+ set = H5Dcreate(fil, DSET1_NAME, H5T_NATIVE_DOUBLE, spc, H5P_DEFAULT);
+ CHECK(set, FAIL, "H5Dcreate");
+
+ att = H5Acreate(set, ATTR1_NAME, H5T_NATIVE_DOUBLE, spc, H5P_DEFAULT);
+ CHECK(att, FAIL, "H5Acreate");
+
+ ret=H5Aread(att, H5T_NATIVE_DOUBLE, &rdata);
+ CHECK(ret, FAIL, "H5Awrite");
+
+ if(rdata!=0.0)
+ TestErrPrintf("attribute value wrong: rdata=%f, should be %f\n",rdata,0.0);
+
+ ret=H5Fflush(fil, H5F_SCOPE_GLOBAL);
+ CHECK(ret, FAIL, "H5Fflush");
+
+ ret=H5Aread(att, H5T_NATIVE_DOUBLE, &rdata);
+ CHECK(ret, FAIL, "H5Awrite");
+
+ if(rdata!=0.0)
+ TestErrPrintf("attribute value wrong: rdata=%f, should be %f\n",rdata,0.0);
+
+ ret=H5Awrite(att, H5T_NATIVE_DOUBLE, &wdata);
+ CHECK(ret, FAIL, "H5Awrite");
+
+ ret=H5Aread(att, H5T_NATIVE_DOUBLE, &rdata);
+ CHECK(ret, FAIL, "H5Awrite");
+
+ if(rdata!=wdata)
+ TestErrPrintf("attribute value wrong: rdata=%f, should be %f\n",rdata,wdata);
+
+ ret=H5Sclose(spc);
+ CHECK(ret, FAIL, "H5Sclose");
+ ret=H5Aclose(att);
+ CHECK(ret, FAIL, "H5Aclose");
+ ret=H5Dclose(set);
+ CHECK(ret, FAIL, "H5Dclose");
+ ret=H5Fclose(fil);
+ CHECK(ret, FAIL, "H5Fclose");
+} /* test_attr_basic_flush() */
+
+/****************************************************************
+**
** test_attr_compound_write(): Test H5A (attribute) code.
** Tests compound datatype attributes
**
@@ -1503,6 +1569,7 @@ test_attr(void)
/* These next two tests use the same file information */
test_attr_basic_write(); /* Test basic H5A writing code */
test_attr_basic_read(); /* Test basic H5A reading code */
+ test_attr_flush(); /* Test H5A I/O in the presence of H5Fflush calls */
/* These next two tests use the same file information */
test_attr_compound_write(); /* Test complex datatype H5A writing code */